링드리스트 질문
소녀틳향기
2024.03.14
질문 제목 : 링크드리스트 질문스텍구조 관련질문 내용 :
#include stdio.h
#include stdlib.h
typedef struct stack{
int data;
struct stack* link;
} stack;
stack *top_stack = null;
void link_list(int data)
{
stack *pstack = (stack*)malloc(sizeof(stack));
if (pstack == null) { printf(memory not allocation \n); exit(0); }
pstack-data = data;
top_stack-link = pstack;
top_stack = pstack;
}
void main(void)
{
int i;
for(i=5; i!=0; i--);
{
link_list(i);
}
}
질문 요점은
pstack-data = data;
top_stack-link = pstack;
top_stack = pstack;
이부분입니다-0-;;
틀린게없는거같은데;;