void main(){ struct student *makeit(),*head=NULL,*stud; struct student *del(struct student *,long); struct student *insert(struct student *head,struct student *stud); long int num; head = makeit(); print(head); stud->num = 7010;stud->score = 99.5;//stud = (struct student*)malloc(sizeof(struct student)); head = insert(head,stud);//when you should insert more than one node,you should malloc a new address. print(head); stud->num = 7013;stud->score = 90.5;//notice the value changed in the chain table. head = insert(head,stud); //print(head); }
void main(){ struct student *mhead,*mp; struct student *makeit(); mhead = creat(); printf("Output the value of chain table:\n"); while(mhead){ printf("Num:%ld, score:%f\n",mhead->num,mhead->score); mhead = mhead->next; } printf("\n"); mp = makeit(); printf("Output the value of chain table:\n"); while(mp){ printf("Num:%ld, score:%f\n",mp->num,mp->score); mp = mp->next; } }
int main(int argc, char **argv) { FILE *tmpfd; char makeMacro[ BUFSIZ ]; char makefileMacro[ BUFSIZ ]; program = argv[0]; init(); SetOpts(argc, argv); Imakefile = FindImakefile(Imakefile); CheckImakefileC(ImakefileC); if (Makefile) tmpMakefile = Makefile; else { tmpMakefile = Strdup(tmpMakefile); (void) mkstemp(tmpMakefile); } AddMakeArg("-f"); AddMakeArg( tmpMakefile ); sprintf(makeMacro, "MAKE=%s", program); AddMakeArg( makeMacro ); sprintf(makefileMacro, "MAKEFILE=%s", Imakefile); AddMakeArg( makefileMacro ); if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL) LogFatal("Cannot create temporary file %s.", tmpMakefile); cleanedImakefile = CleanCppInput(Imakefile); cppit(cleanedImakefile, Template, ImakefileC, tmpfd, tmpMakefile); if (show) { if (Makefile == NULL) showit(tmpfd); } else makeit(); wrapup(); exit(0); }