#include <stdio.h>

#include <stdlib.h>


typedef int element;

typedef struct ListNode

{

element data;

struct ListNode *link;

} ListNode;


void insert_node(ListNode **phead, ListNode*p, ListNode *new_node)

{

if (*phead == NULL)

{

new_node->link = NULL;

*phead = new_node;

}


else if (p == NULL)

{

new_node->link = *phead;

*phead = new_node;

}


else

{

new_node->link = p->link;

p->link = new_node;

}

}


void display(ListNode*head)

{

ListNode *p = head;

while(p != NULL)

{

printf("%d ", p->data);

p = p->link;

}

printf("\n");

}


ListNode *search_odd(ListNode*head)

{

ListNode *p;

p = head;

int sum = 0;

while (p)

{

if (((p->data) % 2) == 1)

{

printf("  %d", p->data);

sum = sum + p->data;

}

p = p->link;

}

printf("\n홀수 원소들\n\n");

printf("홀수 값의 합: %d\n", sum);

return 0;

}


ListNode *create_node(element data, ListNode*link)

{

ListNode *new_node;

new_node = (ListNode*)malloc(sizeof(ListNode));

new_node->>

new_node->link = link;

return(new_node);

}


int main()

{

ListNode *list1 = NULL;

ListNode *p;

int i;

for (i = 0; i < 10; i++)

{

insert_node(&list1, NULL, create_node((rand()0)+1, NULL));

}

display(list1);



p = search_odd(list1);

printf("%d ", p->data);




}


이렇게 했고 에러도 없는데 오류는 왜나는걸까요?