#include <stdio.h> #include <stdlib.h> #include <limits.h> #define FALSE 0 #define TRUE 1 typedef int element; typedef struct ListNode { element data; struct ListNode *link; } ListNode; typedef struct { ListNode *head; // 헤드 포인터 int length; // 노드의 개수 } ListType; // phead: 리스트의 헤드 포인터의 포인터 // p : 선행 노드 // new_node : 삽입될 노드 void error(char *message) { fprintf(stderr,"%s\n",message); exit(1); } void insert_node(ListNode **phead, ListNode *p, ListNode *new_node) //giving way to change headNode itself // previous node to manipulate likes //new data node to insert in the list //to give **phead, new node should know { if( *phead == NULL ){ // 공백리스트인 경우 new_node->link = NULL; *phead = new_node; } else if( p == NULL ){ // if previous node input value is null, means that new node is supposed to be head of the