#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; }
|