#include #include #include #include #include #include /* - TopicsExpress



          

#include #include #include #include #include #include /* definition of a data node for holding student information */ typedef struct student{ int id; char name[20]; struct student *next; }student; student *LIST1 = NULL; student *endLIST1 = NULL; /* function prototypes */ void printlist(student *node); void printnode (student *node); void append(student *newnode); student * initnode (int id,char *name); main(){ char name[20]; int id, ch = 1; clrscr(); while( ch != 0 ) { printf("1 append a name "); printf("2 delete a name "); printf("3 list all names "); printf("4 search for name "); printf("5 insert a name "); printf("0 quit "); scanf("%d", &ch ); switch( ch ) { case 1: /* add a name to end of list */ break; case 2: /* delete a name */ break; case 3: /* list all nodes */ break; case 4: /* search and print name */ break; case 5: /* insert a name in list */ break; } } } student * initnode (int id,char *name){ student *tmp; tmp = new student; if(tmp == NULL) return (student *) NULL; else{ tmp->id = id; strcpy(tmp->name,name); return tmp; } } void append(student *newnode){ if(LIST1 == NULL) LIST1 = newnode; endLIST1->next = newnode; newnode->next - NULL; endLIST1 = newnode; } void printnode (student *node){ printf("ID : %d ",node->id); printf("Name : %s ",node->name); printf("-------------------------- "); } void printlist(student *node){ while(node != NULL){ printnode(node); node = node->next; } }
Posted on: Mon, 15 Jul 2013 07:59:51 +0000

Trending Topics



Recently Viewed Topics




© 2015