|
음..짜긴짯는데.. 저는 틀린곳을 못찾겠습니다 ㅠ.ㅠ;;
고수님 플리즈요~~
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct data {
char name[20];
struct data *next;
};
typedef struct data PERSON;
typedef PERSON *LINK;
main()
{
LINK head = NULL;
LINK new =NULL;
LINK current = NULL;
new = (LINK)malloc(sizeof(PERSON));
new->next =head;
head =new;
strcpy(new->name, "Abigail");
current=head;
while (current->next !=NULL)
{
current=current->next;
}
new =(LINK)malloc(sizeif(PERSON));
current->next =new;
new->next =NULL;
strpy(new->name,"Catherine");
new =(LINK)malloc(sizeof(PERSON));
new->next=head->next;
head->next =new;
strcpy(new->name,"Beatrice");
current =head;
while(current !=NULL)
{
printf("\n%s",current->name);
current=current->next;
}
printf("\n");
return (0);
}
즐거운하루되세용
|