자료구조... 단순연결리스트
난초
10-20-30 이렇게 된 노드를 만들고 싶습니다....
하지만 안됩니다. ㅎㅎ
책을 따라서 해봤는데 `` 어디가 문제인지 잘 몰르겟네요 ...틀린부분을 잡아주시면 감사해요 !!#includestdio.h
#includestdlib.h
typedef int element;
typedef struct listnode{
element data;
struct listnode *link;
}listnode;
listnode *create_node(element data,listnode *link){
listnode *new_node;
new_node=(listnode *)malloc(sizeof(listnode));
}
void display(listnode *head)
{
listnode *p=head;
while(p != null){
printf(%s-, p-data);
p = p-link;
}
printf(\n);
}
void insert_node(listnode **head, listnode *new_node)
{
if(*head=null){
new_node-link = *head-link;
*head-link = new_node-link;
}
else{
new_node-link = null;
*head = new_node;
}
}
void main(){
listnode *list1=null ;
listnode *p;
insert_node(&list1,create_node(10,null));
insert_node(&list1,create_node(20,null));
insert_node(&list1,create_node(30,null));
display(list1);
}