doubly list 정렬하는 건데 왜 오류뜨는지모르겠어요 ㅠㅠ 고수님들 좀봐주세요


#include<stdio.h>

#include<stdlib.h>

#include<string.h>


typedef struct list_node * PTR;

typedef struct list_node {

char data[3];

PTR rlink;

PTR llink;

}list_node;


void printList(PTR * head);

void insert(PTR *ptr, char *item);


void insert(PTR *ptr, char *item)

{

PTR newnode, temp;

newnode = (PTR)malloc(sizeof(PTR));

strcpy(newnode->data, item);


if ((*ptr)->rlink == *ptr) //빈노드일때 노드 추가

{

newnode->rlink = *ptr;

newnode->llink = *ptr;

(*ptr)->rlink = newnode;

(*ptr)->llink = newnode;

temp = newnode;


}


else

{

temp = (*ptr)->rlink;

while (1)

{

if (strcmp(temp->data, item) > 0)

{

newnode->rlink = temp;

newnode->llink = temp->llink;

temp->llink = newnode;

temp->llink->rlink = newnode;


break;

}

else if (((*ptr)->llink->data,item) < 0)

{

newnode->rlink = temp->rlink;

newnode->llink = temp;

temp->rlink = newnode;

temp->rlink->llink = newnode;


break;

}

else

temp = temp->rlink;

}

}

}


void printList(PTR * head) {

PTR temp;


printf("\n<print list>\n");

/* list의 처음부터 끝까지 이동하면서 data값 출력 */

temp = *head;

do

{

temp = temp->rlink;

printf("%s\t", temp->data);

} while (temp->rlink != (*head));

printf("\n");

}


int main(void)

{

FILE *fp;

char input[3];

PTR head;

head = (PTR)malloc(sizeof(PTR)); //더미노드생성

head->rlink = head;

head->llink = head;

strcpy(head->data, NULL);


fp = fopen("Data5.txt", "r");

if (!fp){ printf("Can't read the file\n"); exit(0); }


while (!feof(fp)) {

fscanf(fp, "%s", input); /* 파일에서 하나씩 읽어오면서 리스트에 추가 */

insert(&head, input);


printf("\ninput: %s", input);

printList(&head);

}

printf("\nresult: ");

printList(&head);


fclose(fp);

}