已知C源程序如下: /*A simple mailing list example using an array of structures. */ # include<stdion.h> # include<stdlib.h> define MAX 4 struct addr char name[30]; char street[40]; char city[20]; unsigned long int zip; addr_list[MAX]; void init_list(void),enter(void); void deleteAddr(void),list(void); int menu_select(void),find_free(void); int main(void)
char choice; init_list();/*initialize the structure array*/ for(;;) choice=menu_select(); switch(choice) case 1:enter(); break; case 2:deleteAddr(); break; case 3:list(); break; case 4:exit(0);
return 0;
/*Initialize the list.*/ void initlist(void)
register int t; for(t=0;t<MAX; ++t)addr_list[t], name[0]=\0;
/*Get a menu selection. */ int menu_select(void) char s[80. ; int c; printf("1.Enter a name\n"); printf("2.Delete a name\n"); printf("3.List the file\n"); printf ("4.Quit\") do printf("\nEnter your choice:"); gets(s); c= atoi(s); while(c<1 || c>4); return c;
/*Input addresses into the list. */ void enter(void)
int slot; char s[80]; slot=find_free(); if(slot==-1) printf("\nList Full"); return;