错误提示上一:1.Type mismatch in parameter parameter in call to function 2.Type mismatch in redeclaration of identifier
不明白什么意思~~~~~~~~
#include
struct bank{char id[10];
char password[10];
double money;
}message;
int login_scan(char s[])
{FILE *fp;char str1[30];char str2[10];
int n=1;
if((fp=fopen("f:/data.txt","r"))==NULL)
{printf("sorry,system error\n");
exit(1);
}
fread(str1,sizeof(message.id),1,fp);
fread(str2,sizeof(message.password),1,fp);
strcat(str1,str2);
while(!feof(fp))
{ if(!strcmp(str1,s))
return n;
rewind(fp);
fseek(fp,n*sizeof(struct bank),1);
fread(str1,sizeof(message.id),1,fp);
fread(str2,sizeof(message.password),1,fp);
strcat(str1,str2);
n++;
}
fclose(fp);
return 0;
}
int login(void)//登录函数
{ FILE *fp;char s[30];int flat;int n=3;char str[100];
if((fp=fopen("f:/data.txt","r"))==NULL)
{printf("sorry,system error\n");
exit(1);
}
printf("input your use_name");
scanf("%s",message.id);
printf("iput your password\n");
scanf("%s",message.password);
strcpy(str,message.id);
strcat(str,message.password);//是否会在后面自动补\0?
flat=login_scan(str);
if(flat)
{ printf("login achieve\n");
fclose(fp);
return flat;
}
else
{ printf("you use name or password error!\n");
while(n>0)
{ printf("you have %d chancese input your use name and password:\n ",n);
printf("input your use_name");
scanf("%s",message.id);
printf("iput your password\n");
scanf("%s",message.password);
strcpy(str,message.id);
strcat(str,message.password);
flat=login_scan(message.id);
if(flat)
{ printf("login achieve\n");
fclose(fp);
return flat;
}
printf("you use name or password error!\n");
n--;
}
printf("input error");
fclose(fp);
return 0;
}
}
baidu 限制字数,所以接着发余下的程序,不好意思,是remove的错了
接着上面的程序
int remove(int n)
{
FILE *fp;
double money;
double origin;
if((fp=fopen("f:/data.txt","r+"))==NULL)
{
printf("sorry,system error\n");
exit(1);
}
if(n==0)
printf("error\n");
else
{
fseek(fp,n*sizeof(struct bank)-sizeof(double),0);
printf("input your remove money\n");
scanf("%lf",&money);
if((origin >= money))
{
origin=origin-money;
if(origin>=0)
printf("Your balance is %lf yuan!\n",origin);
}
else
{ origin=origin-money;
printf("Your balance is not enough!you Overdraft %lf yuan\n",-origin);
}
fwrite(&origin,sizeof(double),1,fp);
}
fclose(fp);
return 1;
}
main()
{int x;
x=login();
if(x)
{
remove(x);
}
return 1;
}
|