#include<stdio.h>
#include<string.h>
#include <stdlib.h>
void listInit(void);
void create(void);
void display(void);
struct Node{
char name[20];
struct Node *ptr;
};
struct Node *headp,*tailp,*tp,*np;
void main()
{
int num;
char temp[20];
listInit();
create();
display();
}
void listInit()
{
headp=(struct Node*)malloc(sizeof(struct Node));
tailp=(struct Node*)malloc(sizeof(struct Node));
headp->ptr=tailp;
tailp->ptr=tailp;
headp->ptr->ptr=tailp;
}
void create()
{
char temp[20];
tp=headp;
while(1){
printf("#이름을 입력하세요 :");
gets(temp);
if(strcmp(temp,"END")==0){
break;
}
}
tp->ptr=(struct Node*)malloc(sizeof(struct Node));
tp=tp->ptr;
strcpy(tp->name,temp);
tp->ptr=tailp;
}
void display()
{
tp=headp->ptr;
while(tp!=tailp){
printf("%sn",tp->name);
tp=tp->ptr;
}
}
create함수에서 입력한값을 diaplat함수에서 출력할려고 하는데
create함수안에잇는 while을 빠져나올때 쓰이는 END만 출력되고 전에 입력해놨던 것들은 출력이 안되더군요;
어디서 잘못된건가요 ㅠㅠ;