1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdbool.h>
 
struct _stack
{
    int data;
    struct _stack * next;
}typedef Stack;
 
Stack* push(Stack* stack,int data)
{
    Stack* newstack;
    newstack = (Stack*)malloc(sizeof(Stack*));
    newstack->data = data;
    newstack->next = stack;
    return newstack;
}
 
bool isfull(Stack* stack)
{
    if (stack == NULL)
    {
        return 0;
    }
    return 1;
}
void print(Stack* stack)
{
    Stack* curr = stack;
    printf("현재스택 : ");
    while (curr != NULL)
    {
        printf("%d ", curr->data);
        curr = curr->next;
    }
    printf("\n");
}
Stack* pop(Stack* stack)
{
    if (isfull(stack))
    {
        printf("삭제된 데이터 : %d\n"stack->data);
        stack=stack->next;
        return stack;
    }
    printf("스택이 비어있음\n");
}
 
int main()
{
    Stack* stack =NULL;
    Stack* curr;
    int data;
    stack = pop(stack);
    stack = push(NULL3);
    stack = push(stack5);
    stack = push(stack10);
    print(stack);
    stack = pop(stack);
    print(stack);
}
cs



pop에서 free를 해주고싶은데 할필요가없음?