int *ID=NULL,*In=NULL,*Exp=NULL,choice,num;
char **Name=NULL;
for(;;)
{
printf("1.Input record\n");
printf("2.Sort and list records in alphabetical order by user name\n");
printf("3.Search records by user name\n");
printf("4.Calculate and list per capita income and expenses\n");
printf("5.List records which have more expenses than per capita expenses\n");
printf("6.List all records\n");
printf("0.Exit\n");
printf(" Please enter your choice: ");
scanf("%d",&choice);
if(choice==1)
{
int i;
printf("The number of users is ");
scanf("%d",&num);
ID=(int*)calloc(num,sizeof(int));
In=(int*)calloc(num,sizeof(int));
Exp=(int*)calloc(num,sizeof(int));
char **Name=(char**)calloc(num,sizeof(char*));
for(i=0;i<num;i++)
{
Name[i]=(char*)calloc(N,sizeof(char));
}
Input(ID,Name,In,Exp,num);
Print(ID,Name,In,Exp,num);
}
else if(choice==2)
{
}
else if(choice==3)
{
}
else if(choice==4)
{
}
else if(choice==5)
{
}
else if(choice==6)
{
Print(ID,Name,In,Exp,num);
}
else if(choice==0)
{
int i;
free(ID);
free(In);
free(Exp);
for(i=0;i<num;i++)
{
free(Name[i]);
}
free(Name);
return 0;
}
else
{
printf("error!\n");
}
}
void Input(int *ID,char *Name[],int *In,int *Exp,int num)
{
int i;
for(i=0;i<num;i++)
{
printf("Please input record:\n");
scanf("%d%s%d%d",&ID[i],Name[i],&In[i],&Exp[i]);
}
printf("record end!\n");
}