| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1086 人关注过本帖
标题:搞不懂的一个错误~~~那么多人看就没一个能讲一下?
只看楼主 加入收藏
tiw
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2008-2-13
收藏
 问题点数:0 回复次数:3 
搞不懂的一个错误~~~那么多人看就没一个能讲一下?
错误提示上一: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]]
搜索更多相关主题的帖子: parameter 函数 讲解 变量 mismatch 
2008-06-16 17:39
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
我用VC编译了一下:
--------------------Configuration: help4 - Win32 Debug--------------------
Compiling...
Main.cpp
E:\Microsoft Visual C++\MyProjects\临时\help4\Main.cpp(43) : warning C4101: 's' : unreferenced local variable('s' 未使用)
E:\Microsoft Visual C++\MyProjects\临时\help4\Main.cpp(110) : warning C4700: local variable 'origin' used without having been initialized('origin' 未初始化)
E:\Microsoft Visual C++\MyProjects\临时\help4\Main.cpp(134) : warning C4700: local variable 'origin' used without having been initialized('origin' 未初始化)
Linking...

help4.exe - 0 error(s), 0 warning(s)


#include <stdio.h>
#include <string.h>
#include <stdlib.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] 本帖最后由 flyue 于 2008-6-16 18:09 编辑 [/it]]

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2008-06-16 18:08
tiw
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2008-2-13
收藏
得分:0 
还是不行,我详细想明白那两个错误的意思,
2008-06-16 21:05
tiw
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2008-2-13
收藏
得分:0 
remove是库函数,而其它的要在使用时先在前面定义
2008-07-03 12:28
快速回复:搞不懂的一个错误~~~那么多人看就没一个能讲一下?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019153 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved