#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node{
 int data;
 struct node *link;
}Node;
Node *createNode(int data){
 Node *newNode = (Node*)malloc(sizeof(Node));
 newNode->> newNode->link = NULL;
 
 return newNode;
}
void insertNode(Node **head, int data){
 Node *p;       //
 p = *head;    //  이두부분 Node *p = *head; 로 바꾸면 안돌아가는데 뭔차이임??
 
 if(*head == NULL){
  *head = createNode(data);
  return;
 }
 
 
 while(p->link != NULL)
  p = p->link;
  
 p->link = createNode(data);
}
void main(){
 Node *head = NULL;
 
 insertNode(&head, 10);
 insertNode(&head, 20);
 insertNode(&head, 30);
 
 for(head; head!=NULL; head=head->link){
  printf("%d\n", head->data);
 }

}