搞不懂的一个错误~~~那么多人看就没一个能讲一下?
错误提示上一:1.Type mismatch in parameter parameter in call to function 源文件说明一个具有原型的命名函数,命名的参数不能转换成所说明的参数类型。
2.Type mismatch in redeclaration of identifier 源文件中对一个已说明过的变
量用不同类型重说明。这可能是在一个函数被调用而后面的说明为返回一个非整型的类型。
若是这种情况你必须在第一次调用它之前说明该函数。
不明白什么意思~~~~~~~~
#include<stdio.h。
#include<string.h>
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;
}
}
int save(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 save money\n");
scanf("%lf",&money);
origin=origin+money;
fwrite(&origin,sizeof(double),1,fp);
printf("save money Success,you have %lf yuan now\n",origin);
}
fclose(fp);
return 1;
}
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()
{ FILE *fp;
char s[30];
double m;
int x;
x=login();
if(x)
{ save(x);
remove(x);
}
if((fp=fopen("f:/data.txt","r"))==NULL)
{
printf("sorry!system error!\n");
exit(1);
}
fread(s,sizeof(message.id),1,fp);
printf("%s",s);
rewind(fp);
fseek(fp,20,1);
fread(&m,sizeof(message.money),1,fp);
printf("%lf",m);
fclose(fp);
return 1;
}
[[it] 本帖最后由 tiw 于 2008-6-17 14:33 编辑 [/it]]