| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 517 人关注过本帖
标题:一个多文件编程,3个错误function does not take 0 parameters。。之前也有 ...
只看楼主 加入收藏
赵余
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-4-29
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
一个多文件编程,3个错误function does not take 0 parameters。。之前也有这个错误但是因为参数个数问题,但现在好像不是,,,弄不
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
struct book_information{
    char name[20];    //书名
    char chuban[20]; //出版
    char year[5];    //年号
    char ISBN[20];   
    char number[20];  //书号
    char zhubian[20];   //主编
    char shuliang[2];
};
typedef struct book_information book;
extern int numbook;   //图书数量
extern book*records;//图书信息
extern char savedTag;//信息保存标志
void handle_menu(void);
int menu_select(int);
void jiechu(void);
void guihuan(void);
int find(char*target,int targetType,int from);
void add(void);
void modify(void);
int saveRecords(int);
void showTable(void);
void quit(void);


#include"head.h"
int numbook=0;
book*records=NULL;
char savedTag=0;
void main()
{
    int i,A;
    printf("\t************************************************\n");
    printf("\t            欢迎使用广商图书管理系统            \n");
    printf("\t                                                \n");
    printf("\t                                                \n");
    printf("\t                                                \n");
    printf("\t                                                \n");
    printf("\t                                                \n");
    printf("\t                                                \n");
    printf("\t                                设 计 人:      \n");
    printf("\t                                    级:      \n");
    printf("\t                                指导老师:      \n");
    printf("\t                                时间:2015.04.14\n");
    printf("\t************************************************\n");
    printf("请输入图书管理员用户密码:");
    scanf("%d",&A);
    for(i=1;i<=3;i++)
    if(A!=123)
    {
        printf("密码错误,请重新输入:");
        scanf("%d",&A);
    }
    handle_menu();
}
void handle_menu()
{
    for(;;){
        switch(menu_select())//这里为什么错了?
        {
        case 1:
            jiechu();
            break;
        case 2:
            guihuan();
            break;
        case 3:
            find();//这里为什么又错了?T_T
            break;
        case 4:
            add();
            break;
        case 5:
            modify();
            break;
        case 6:
            quit();
        }
    }
}
int menu_select(int)
{
    char s[2];
    int cn=0;
    printf("\n");
    printf("\t1.借出图书\n");
    printf("\t2.归还图书\n");
    printf("\t3.查找图书\n");
    printf("\t4.添加图书\n");
    printf("\t5.修改图书\n");
    printf("\t6.退出程序\n");
    printf("\n\t左边序号对应功能选择,请选择1-6:\n");
    for(;;)
    {
        gets(s);
        cn=atoi(s);
        if(cn<1||cn>9)printf("\n\t请重新选择,1-6:\n");
        else break;
    }
    return cn;
}
void quit()
{
    char str[5];
    if(savedTag==1)
    {
        printf("是否保存原来的记录?(Y/N)");
        gets(str);
        if(str[0]!='N')
            saveRecords();//这里为什么还错了。。。奔泪
    }
    free(records);
    exit(0);
}




#include"head.h"
void jiechu(void)
{
    char str[5];
    char target[20];
    int type;
    int i;
    int tmpi;
    float sum,mark;
    int count = 0;   

    if(numbook==0)
    {
        printf("没有可供借出的图书");
        return;
    }

    while(1) {
        printf("请输入如何找到欲借出的图书的方式:\n");
        printf("1. 按书名\n");
        printf("2. 按主编\n");
        printf("3. 按书号\n");
        gets(str);
        if (strlen(str) == 0) break;

        if (str[0] == '1')
        {
            printf("请输入该图书的书名:");
            gets(target);
            type = 0;
        } else if (str[0] == '2')
        {
            printf("请输入该图书的主编:");
            gets(target);
            type = 1;
        } else
        {
            printf("请输入该图书的书号:");
            gets(target);
            type = 2;
        }

        i = find(target,type,0);
        if (i==-1) printf("没有符合条件的图书!\n");

        while(i != -1)
        {
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            printf("确定要借入这个图书吗?(y/N)");
            gets(str);
            if (str[0]=='y' || str[0]=='Y')    printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                                                   records[i].name,records[i].zhubian,records[i].chuban,
                                                   records[i].year,records[i].ISBN,records[i].number,records[i].shuliang-1);
        }
    }
}





#include"head.h"
void guihuan(void)
{
    char str[5];
    char target[20];
    int type;
    int i;
    int count = 0;
    while(1) {
        printf("请输入如何找到欲归还的图书的方式:\n");
        printf("1. 按书名\n");
        printf("2. 按主编\n");
        printf("3. 按书号\n");
        gets(str);
        if (strlen(str) == 0) break;

        if (str[0] == '1')
        {
            printf("请输入该图书的书名:");
            gets(target);
            type = 0;
        } else if (str[0] == '2')
        {
            printf("请输入该图书的主编:");
            gets(target);
            type = 1;
        } else
        {
            printf("请输入该图书的书号:");
            gets(target);
            type = 2;
        }

        i = find(target,type,0);
        if (i==-1) printf("没有符合条件的图书!\n");

        while(i != -1)
        {
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            printf("确定要归还这个图书吗?(y/N)");
            gets(str);
            if (str[0]=='y' || str[0]=='Y')    printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                                                   records[i].name,records[i].zhubian,records[i].chuban,
                                                   records[i].year,records[i].ISBN,records[i].number,records[i].shuliang+1);
        }
    }
}




#include"head.h"
void add(void)
{
    if(numbook==0)
        printf("原来没有记录,现在记入新的图书信息\n");
    else
        printf("下面在已有图书信息末尾添加新的信息\n");
    while(1)
    {
        printf("请输入书名:");
        gets(records[numbook].name);
        printf("请输入主编:");
        gets(records[numbook].zhubian);   
         printf("请输入出版:");
        gets(records[numbook].chuban);
        printf("请输入年号:");
        gets(records[numbook].year);
        printf("请输入ISBN:");
        gets(records[numbook].ISBN);
        printf("请输入书号:");
        gets(records[numbook].number);
        printf("请输入数量:");
        gets(records[numbook].shuliang);
        numbook++;
    }
    printf("新图书已录入成功!\n");
    printf("现在一共有%d本图书\n",numbook);
    savedTag=1;
}




#include"head.h"
void find(int )
{
    char str[5];
    char target[20];
    int type;
    int count;
    int i;
    if(numbook==0)
    {
        printf("没有可查询的记录\n");
        return;
    }
    while(1)
    {
        printf("请选择查询方式:\n");
        printf("1.按书名\n");
        printf("2.按主编\n");
        printf("3.按书号\n");
        gets(str);
        if(str[0]=='1')
        {
            printf("请输入欲查询的图书的书名:\n");
            gets(target);
            type=0;
        }
        if(str[0]=='2')
        {
            printf("请输入欲查询的图书的主编:\n");
            gets(target);
            type=1;
        }
        if(str[0]=='3')
        {
            printf("请输入欲查询的图书的书号:\n");
            gets(target);
            type=2;
        }
        i=find(target,type,0);
        count=0;
        while(i!=-1)
        {
            count++;
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            i=find(target,type,i+1);
        }
        if(count==0)printf("没有合适的图书\n");
        else printf("一共找到了%d本图书\n",count);
    }
}





#include"head.h"
void modify(void)
{
    char str[5];
    char target[20];
    int type;
    int i;
    int tmpi;
    float sum,mark;
    int count = 0;   

    if(numbook==0)
    {
        printf("没有可供修改的记录");
        return;
    }

    while(1) {
        printf("请输入如何找到欲修改的图书的方式:\n");
        printf("1. 按书名\n");
        printf("2. 按主编\n");
        printf("3. 按书号\n");
        gets(str);
        if (strlen(str) == 0) break;

        if (str[0] == '1')
        {
            printf("请输入该图书的书名:");
            gets(target);
            type = 0;
        } else if (str[0] == '2')
        {
            printf("请输入该图书的主编:");
            gets(target);
            type = 1;
        } else
        {
            printf("请输入该图书的书号:");
            gets(target);
            type = 2;
        }

        i = find(target,type,0);
        if (i==-1) printf("没有符合条件的图书!\n");

        while(i != -1)
        {
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            printf("确定要修改这个图书的信息吗?(y/N)");
            gets(str);
            if (str[0]=='y' || str[0]=='Y')
            {
                printf("下面请重新输入该图书的信息:\n");
                printf("请输入书名:");
                gets(records[i].name);
                printf("请输入主编:");
                gets(records[i].zhubian);
                printf("请输入出版:\n");
                gets(records[i].chuban);
                printf("请输入年号:\n");
                gets(records[i].year);
                printf("请输入ISBN\n");
                gets(records[i].ISBN);
                printf("请输入书号:\n");
                gets(records[i].number);
                printf("请输入数量:");
                gets(records[i].shuliang);
            }
            i=find(target,type,i+1);
        }
    }
    savedTag=1;
}
搜索更多相关主题的帖子: function include records number 信息 
2015-04-29 23:59
wmf2014
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:216
帖 子:2039
专家分:11273
注 册:2014-12-6
收藏
得分:14 
简单看了下,有几个问题
1,没有提供head.h头文件,并且多处重复include它
2,定义的函数和函数实体形参以及调用该函数的实参不一致,比如find函数,预定义是“int find(char*target,int targetType,int from);”,函数实体是“void find(int )”,调用有两种形式,一种是“i=find(target,type,0);”有实参和返回参数,一种是“find();”无返回参数无调用实参。
3,预定义函数但没有函数实体,如saveRecords函数
问题总结:你可能只是拷贝了别人的部分代码,没有得到别人的全部工程文件。

能编个毛线衣吗?
2015-04-30 06:24
赵余
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-4-29
收藏
得分:0 
1.开头就是头文件呢。
2.我把查找功能改如下,可以么;
#include"head.h"
int find(char*target,int targetType,int from )
{
    int i;
    for(i=from;i<numbook;i++)
    {
        if((targetType==0&&strcmp(target,records[i].name)==0)||
            (targetType==1&&strcmp(target,records[i].zhubian)==0)||
            (targetType==2&&strcmp(target,records[i].number)))
            return i;
    }
    return -1;
}
void queryInfo(void)
{
    char str[5];
    char target[20];
    int type;
    int count;
    int i;
    if(numbook==0)
    {
        printf("没有可查询的记录\n");
        return;
    }
    while(1)
    {
        printf("请选择查询方式:\n");
        printf("1.按书名\n");
        printf("2.按主编\n");
        printf("3.按书号\n");
        gets(str);
        if(str[0]=='1')
        {
            printf("请输入欲查询的图书的书名:\n");
            gets(target);
            type=0;
        }
        if(str[0]=='2')
        {
            printf("请输入欲查询的图书的主编:\n");
            gets(target);
            type=1;
        }
        if(str[0]=='3')
        {
            printf("请输入欲查询的图书的书号:\n");
            gets(target);
            type=2;
        }
        i=find(target,type,0);
        count=0;
        while(i!=-1)
        {
            count++;
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            i=find(target,type,i+1);
        }
        if(count==0)printf("没有合适的图书\n");
        else printf("一共找到了%d本图书\n",count);
    }
}
3.saverecords,我遗漏复制上来了。如下
#include"head.h"
int saveRecords(int)
{
    FILE *fp;
    char fname[30];   

    if (numbook == 0)
    {      
        printf("没有记录可存!");
          return -1;
    }

    printf("请输入要存入的文件名(直接回车选择文件book):");
    gets(fname);
    if (strlen(fname) == 0)
        strcpy(fname,"book");
  
    if ((fp=fopen(fname,"wb"))==NULL)
    {
        printf("不能存入文件!\n");
        return -1;
    }
 
    printf("\n存文件...\n");
    fwrite(records,sizeof(book)*numbook,1,fp);   
    fclose(fp);
    printf("%d条记录已经存入文件,请继续操作。\n",numbook);   
    savedTag = 0;    // 更新是否已保存的标记
    return 0;
  }
4.这是根据一个学生成绩信息管理软件改过来。。。意在变成图书管管理软件
5.纠结快一星期了。。。。
2015-04-30 23:36
赵余
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-4-29
收藏
得分:0 
回复 楼主 赵余
1.开头就是头文件呢。
2.我把查找功能改如下,可以么;
#include"head.h"
int find(char*target,int targetType,int from )
{
    int i;
    for(i=from;i<numbook;i++)
    {
        if((targetType==0&&strcmp(target,records[i].name)==0)||
            (targetType==1&&strcmp(target,records[i].zhubian)==0)||
            (targetType==2&&strcmp(target,records[i].number)))
            return i;
    }
    return -1;
}
void queryInfo(void)
{
    char str[5];
    char target[20];
    int type;
    int count;
    int i;
    if(numbook==0)
    {
        printf("没有可查询的记录\n");
        return;
    }
    while(1)
    {
        printf("请选择查询方式:\n");
        printf("1.按书名\n");
        printf("2.按主编\n");
        printf("3.按书号\n");
        gets(str);
        if(str[0]=='1')
        {
            printf("请输入欲查询的图书的书名:\n");
            gets(target);
            type=0;
        }
        if(str[0]=='2')
        {
            printf("请输入欲查询的图书的主编:\n");
            gets(target);
            type=1;
        }
        if(str[0]=='3')
        {
            printf("请输入欲查询的图书的书号:\n");
            gets(target);
            type=2;
        }
        i=find(target,type,0);
        count=0;
        while(i!=-1)
        {
            count++;
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            i=find(target,type,i+1);
        }
        if(count==0)printf("没有合适的图书\n");
        else printf("一共找到了%d本图书\n",count);
    }
}
3.saverecords,我遗漏复制上来了。如下
#include"head.h"
int saveRecords(int)
{
    FILE *fp;
    char fname[30];   

    if (numbook == 0)
    {      
        printf("没有记录可存!");
          return -1;
    }

    printf("请输入要存入的文件名(直接回车选择文件book):");
    gets(fname);
    if (strlen(fname) == 0)
        strcpy(fname,"book");
  
    if ((fp=fopen(fname,"wb"))==NULL)
    {
        printf("不能存入文件!\n");
        return -1;
    }

    printf("\n存文件...\n");
    fwrite(records,sizeof(book)*numbook,1,fp);   
    fclose(fp);
    printf("%d条记录已经存入文件,请继续操作。\n",numbook);   
    savedTag = 0;    // 更新是否已保存的标记
    return 0;
  }
4.这是根据一个学生成绩信息管理软件改过来。。。意在变成图书管管理软件
5.纠结快一星期了。。。。
2015-04-30 23:37
赵余
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-4-29
收藏
得分:0 
回复 2楼 wmf2014
1.开头就是头文件呢。
2.我把查找功能改如下,可以么;
#include"head.h"
int find(char*target,int targetType,int from )
{
    int i;
    for(i=from;i<numbook;i++)
    {
        if((targetType==0&&strcmp(target,records[i].name)==0)||
            (targetType==1&&strcmp(target,records[i].zhubian)==0)||
            (targetType==2&&strcmp(target,records[i].number)))
            return i;
    }
    return -1;
}
void queryInfo(void)
{
    char str[5];
    char target[20];
    int type;
    int count;
    int i;
    if(numbook==0)
    {
        printf("没有可查询的记录\n");
        return;
    }
    while(1)
    {
        printf("请选择查询方式:\n");
        printf("1.按书名\n");
        printf("2.按主编\n");
        printf("3.按书号\n");
        gets(str);
        if(str[0]=='1')
        {
            printf("请输入欲查询的图书的书名:\n");
            gets(target);
            type=0;
        }
        if(str[0]=='2')
        {
            printf("请输入欲查询的图书的主编:\n");
            gets(target);
            type=1;
        }
        if(str[0]=='3')
        {
            printf("请输入欲查询的图书的书号:\n");
            gets(target);
            type=2;
        }
        i=find(target,type,0);
        count=0;
        while(i!=-1)
        {
            count++;
            printf("书名:%s\n主编:%s\n出版:%s\n年号:%s\nISBN:%s\n书号:%s\n数量:%s\n",
                  records[i].name,records[i].zhubian,records[i].chuban,
                  records[i].year,records[i].ISBN,records[i].number,records[i].shuliang);
            i=find(target,type,i+1);
        }
        if(count==0)printf("没有合适的图书\n");
        else printf("一共找到了%d本图书\n",count);
    }
}
3.saverecords,我遗漏复制上来了。如下
#include"head.h"
int saveRecords(int)
{
    FILE *fp;
    char fname[30];   

    if (numbook == 0)
    {      
        printf("没有记录可存!");
          return -1;
    }

    printf("请输入要存入的文件名(直接回车选择文件book):");
    gets(fname);
    if (strlen(fname) == 0)
        strcpy(fname,"book");
  
    if ((fp=fopen(fname,"wb"))==NULL)
    {
        printf("不能存入文件!\n");
        return -1;
    }

    printf("\n存文件...\n");
    fwrite(records,sizeof(book)*numbook,1,fp);   
    fclose(fp);
    printf("%d条记录已经存入文件,请继续操作。\n",numbook);   
    savedTag = 0;    // 更新是否已保存的标记
    return 0;
  }
4.这是根据一个学生成绩信息管理软件改过来。。。意在变成图书管管理软件
5.纠结快一星期了。。。。
2015-04-30 23:38
快速回复:一个多文件编程,3个错误function does not take 0 parameters。。之前 ...
数据加载中...
 
   



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

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