#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);
}
}
http://cfile30.uf.tistory.com/image/213F893552CB556B2C3F19
별 하나에 추억과... 별 하나에 사랑과...
*head 별빼