offffffffffffffffff finally it worksCode:#include<stdio.h> #include<string.h> #include<stdlib.h> struct info { char name[50]; char age[50]; struct info *next; }; struct info * allocate(void); void get_elements(struct info *t); #define ADD "add" #define PRINT "print" int main() { struct info *root; struct info *current; char *command; int x=0; root=NULL; while(1) { printf("Enter Command:"); scanf("%s",command); getchar(); if(strcmp(command,ADD)==0) { if(root==NULL) { root=allocate(); get_elements(root); current=root; } else { current->next=allocate(); get_elements(current->next); current=current->next; } } else if(strcmp(command,PRINT)==0) { if(root==NULL) { fprintf(stderr,"There Is No List\n"); exit(1); } else { current=root; printf("---------------------------------------\n"); printf("Recorde\t\tName\t\tAge\n"); printf("--------------------------------------\n"); while(current!=NULL) { x++; printf("%d\t\t%s\t\t%s\n",x,current->name,current->age); current=current->next; } break; } } else { printf("Undefined Command %s\n",command); } } exit(EXIT_SUCCESS); } struct info *allocate() { struct info *t; t=malloc(sizeof(struct info)); return t; } void get_elements(struct info *t) { printf("Enter Your Name:"); scanf("%s",t->name); getchar(); printf("Enter Your Age:"); scanf("%s",t->age); getchar(); }
thanks all