블로그 이미지
송시혁

calendar

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

Notice

Tag

Recent Post

Recent Comment

Recent Trackback

Archive

10- 3예제 응용


#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
  char data;
  struct node *next;
}NODE;
  
int main()
{
  NODE *list, *temp;
  list = (NODE *) malloc (sizeof(NODE));

  list->data = 'a';
  list->next =(NODE *) malloc (sizeof(NODE));
  
  list->data ='b';
  list->next->next=(NODE *) malloc(sizeof(NODE));
  
  list->next->next->data = 'c';
  list->next->next->next = NULL;
  
  temp = list;
  
  while (0!=temp)
  {
    printf("%5c\n", temp->data);
    list = list->next;
    free(temp);
    temp = list;
    
  }
  free(list);
  return 0;
}

  
while (NULL!=temp)
  {
    printf("%5c\n", temp->data);
   tmep = tmep->next;
    
    
    
  }




  




posted by 송시혁