http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=1533 [º¹»ç]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct data{
char name[30];
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(sizeof(PERSON));
current->next = new;
new->next=NULL;
strcpy(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;
}
¿Ö ¾ÈµÇ´Â°ÅÁÒ??
ºÎŹµå¸³´Ï´Ù..
Á¦°¡ Ãʺ¸¶ó¼.. |
Hit : 3143 Date : 2008/01/02 12:01
|