교수님께서 알려주신 사이트에서 예제를 퍼왔습니다. -[허아영] {{{~cpp #include #include #include typedef struct _slist List; typedef struct _slist{ int num; List *next; List *prev; }List; #include "ExList.h" void ShowList(List *plist) { List *p; p=plist; while(p) { printf("%d\n",p->num); p=p->next; } } void main() { List *pList,*pNew,*pIns; pList=(List *)malloc(sizeof(List)); pList->next=0; pList->prev=0; pList->num=1; printf("root생성시\n"); ShowList(pList); pNew=(List *)malloc(sizeof(List)); pList->next=pNew; pNew->num=2; pNew->prev=pList; pNew->next=0; printf("pNew생성시\n"); ShowList(pList); pIns=(List *)malloc(sizeof(List)); pIns->num=3; pIns->prev=pList; pIns->next=pNew; pList->next=pIns; pNew->prev=pIns; printf("pIns삽입시\n"); ShowList(pList); pList->next=pNew; pNew->prev=pList; free(pIns); printf("pIns 삭제시\n"); ShowList(pList); free(pNew); free(pList); } }}} ---- [LinkedList]