function does not take 0 parameter这是出了什么问题 详见代码
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#define N 4;
FILE*fp;
//建立日期函数
struct date
{
unsigned short year;
unsigned short month;
unsigned short day;
};
//建立函数结构体存储信息
struct person
{
int num; //序号
char name[10];
int mobilenum; //手机号码
int homenum; //家庭电话
char email;
char address[30]; //通讯地址
struct date birthday;
};
//编写建立信息文件函数,从键盘输入N个人的信息,并转存到文件中
int mkfile(char*filename,person per[],int n)
{
FILE*fp;
int i,flag=1;
if((fp=fopen(filename,"wb"))==NULL)
{
printf("can not open this file\n");
exit(0);
}
printf("请输入%d个人的以下信息:\n",n);
printf("\n\n\t\t======================================================\n");
printf("\n\n\t\t%-6s%-6s%-6s%-6s%-6s%-6s%-6s\n","序号","姓名","手机号码","家庭号码","电子邮件","通讯地址","出生日期");
for(i=0;i<n;i++)
{
scanf("\t\t%d\t\t%-6s%d\t\t%d%-6s%-6s\t\t%d%d%d\n",&per[i].num ,&per[i].name ,&per[i].mobilenum,&per[i].homenum,&per[i].email,&per[i].address,&per[i].birthday.year,&per[i].birthday.month,&per[i].birthday.day);
if(fwrite(&per[i],sizeof(per),1,fp)!=1)
{
flag=0;
break;
}
}
fclose(fp);
return flag;
}
//显示函数
int show(char*filename,person per[],int n)
{
FILE*fp;
int i,flag=1;
if((fp=fopen(filename,"rb"))==NULL)
{
printf("cannot open this file\n");
exit(0);
}
for(i=0;i<n;i++)
if(fread(&per[i],sizeof(per),1,fp)!=1)
{ flag=0;
break;
}
else
printf("%d%s%d%d%s%s%d",&per[i].num ,&per[i].name ,&per[i].mobilenum,&per[i].homenum,&per[i].email,&per[i].address,&per[i].birthday);
fclose(fp);
return flag;
}
//建立查找函数
int seekInfo(char*filename,person per[],int n)
{
char seekname[10];
FILE*fp;
int i,flag=1;
printf("please input seekname %s",seekname);
scanf("%s",&seekname);
for(i=0;i<n;i++)
if(seekname==per[i].name) //实现查找功能的关键代码
printf("%d%s%d%d%s%s%d",&per[i].num ,&per[i].name ,&per[i].mobilenum,&per[i].homenum,&per[i].email,&per[i].address,&per[i].birthday);
else
flag=0;
fclose(fp);
return flag;
}
//建立添加信息的函数
void addInfo(char*filename, int n)
{
FILE*fp;
char str[100];
if((fp=fopen("filename","a"))==NULL)
{
printf("cannot open this file\n");
exit(0);
}
else
printf("请输入需添加的信息:%s",str);
gets(str);
fputs(str,fp);
fclose(fp);
if((fp=fopen("filename","r"))==NULL)
{
printf("cannot open this file\n");
exit(0);
}
fgets(str,n,fp);
puts(str);
fclose(fp);
return ;
}
//建立删除函数
void deletInfo(char*filename,person per[],int n)
{
char deletname[10];
int i;
int count=N;
printf("请输入需要删除信息的人名:%s",deletname);
scanf("%s",&deletname);
for(i=0;i<n;i++)
{
if(deletname==per[i].name)
per[i]=per[i+1]; //以向前赋值的方法实现个人信息的向前移动,进而删除了第i 个人的信息
}
count-=1; //通讯录删除某个信息后的人数
printf("删除信息后的通讯录:");
for(i=0;i<count;i++)
printf("%d%s%d%d%s%s%d",&per[i].num ,&per[i].name ,&per[i].mobilenum,&per[i].homenum,&per[i].email,&per[i].address,&per[i].birthday);
printf("\n");
}
//主函数
int main()
{
int k;
while(1)
{
printf("\n");
printf("这是一个通讯录\n");
printf("\n");
printf("1----创建通讯录\n");
printf("2----查找通讯录信息\n");
printf("3----添加通讯录信息\n");
printf("4----删除通讯录\n");
printf("0----退出\n");
printf("请选择:");
scanf("%d",&k);
switch(k)
{
case 0: exit(0);
case 1: fp=mkfile();
continue;
case 2:fp=seekInfo();
continue;
case 3:addInfo();
continue;
case 4:deletInfo();
continue;
}
return 0;
}
}
帮忙找找错哈
[ 本帖最后由 cyuyan793445 于 2013-3-3 11:47 编辑 ]