משיהו כאן מבין בC? אם כן,מה לא טוב?
#include<malloc.h> #include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct bla { char name[20]; int Grade; struct std *next; }std; void add(std *tail,std *head); void printall(std *head); void main() { int option=0; int clr=0; int ready=1; std *tail=NULL; std *head=NULL; do { for(clr=0;clr<10 && ready;clr++) printf("********************************************************************************\n"); ready=1; printf("\n\nPlease choose an option : \n1)add a student\n2)search for a student\n3)delete a student\n4)print all of the students\n5)exit\n"); scanf("%d",&option); switch(option) { case 1:add(tail,head);ready=0;break; case 4

rintall(head);ready=0;break; case 5:exit(0); default : printf("\nerror : you gave an invlaid input!\n\n");ready=0; } } while(1); exit(1); } void add(std *tail,std *head) { std *i; int clr=0,grade=0; char tmp[20]; printf("please insert the students name :"); scanf("%s",tmp); printf("\ngood! now, please inset %s's grade : ",tmp); scanf("%d",&grade); if(head==NULL) { printf("head is NULL!"); head=(std*)malloc(sizeof(std)); if(head==NULL) exit(1); tail=head; strcpy(head->name,tmp); head->Grade=grade; } else { i=(std*)malloc(sizeof(std)); if(i==NULL) exit(1); tail->next=i; strcpy(i->name,tmp); i->Grade=grade; } } void printall(std *head) { std *i; if(head==NULL) { printf("\nerror : there are no students yet!"); return; } i=head; while(i!=NULL) { printf("the students name is: %s and his grade is %d\n",i->name,i->Grade); i=i->next; } }