| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4868 人关注过本帖
标题:老出现struct Info *()' differs in levels of indirection from 'int ()'
只看楼主 加入收藏
星空下的雪
Rank: 1
等 级:新手上路
帖 子:13
专家分:9
注 册:2012-11-17
结帖率:50%
收藏
 问题点数:0 回复次数:4 
老出现struct Info *()' differs in levels of indirection from 'int ()'
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
enum Sex{male,female};           /*性别*/
enum Education{high,junior,college,master,doctor};      /*学历*/
struct Date                      /*日期*/
{
    int year;
    int month;
    int day;
};
typedef struct Info
{
    char num[10];                /*职工号*/
    char name[15];               /*姓名*/
    enum Sex sex;                /*性别*/
    struct Date birthday;        /*出生年月*/
    enum Education education;    /*学历*/
    char duty[15];               /*职务*/
    double wage;                 /*工资*/
    char addr[30];               /*地址*/
    char phone[15];              /*电话*/
    struct Info * next;
}Info;

struct Info* LinkList_creat();
struct Info* LinkList_insert(struct Info *head);
void LinkList_display(struct Info *head);
void LinkList_delete(struct Info *head);
void LinkList_find(struct Info *head);
struct Info* LinkList_change(struct Info *head);

int main()
{
  char choose;
  struct Info *head;
  head=NULL;
  while(1)
  {
        printf("\n**************** Command Menu ****************\n");  
        printf("**************** 1:信息录入 ****************\n");  
        printf("**************** 2:插入信息 ****************\n");  
        printf("**************** 3:信息删除 ****************\n");  
        printf("**************** 4:信息浏览 ****************\n");  
        printf("**************** 5:信息查询 ****************\n");
        printf("**************** 6:信息修改 ****************\n");   
        printf("**************** 7:退    出 ****************\n\n");
        printf("**************** ps:本系统使用无头链表 系统bug:num必须互斥 以num ID 优先操作****************\n");        
        choose=getch();  
        switch(choose)  
        {  
            case '1':  
                {  
                    if(head!=NULL)  
                    {  
                        printf("A linklist exists already!\n\n");  
                        break;  
                    }  
                    else  
                    { head=LinkList_create();  
                    break;  }
                }  
            case '2':  
                {  
                    if(head==NULL)  
                    {  
                        printf("No list has been created!Choose again!\n\n");  
                        break;  
                    }  
                    else  
                        head=LinkList_insert(head);  
                    break;  
                }  
            case '3':  
                {  
                    if(head==NULL)  
                    {  
                        printf("No list has been created!Choose again!\n\n");  
                        break;  
                    }  
                    else  
                        LinkList_delete(head);  
                    break;                    
                }  
            case '4':  
                {  
                    if(head==NULL)  
                    {  
                        printf("No list has been created!Choose again!\n\n");  
                        break;  
                    }  
                    else  
                        LinkList_display(head);  
                    break;                    
                }  
            case '5':  
                {     
                    if(head==NULL)  
                    {  
                        printf("No list has been created!Choose again!\n\n");  
                        break;  
                    }  
                    else  
                        LinkList_find(head);  
                    break;  
                }  
            case '6':  
                {  
                    if(head==NULL)  
                    {  
                        printf("No list has been created!Choose again!\n\n");  
                        break;  
                    }  
                    else  
                        head=LinkList_change(head);  
                    break;                    
                }
            case '7':  
                {     
                    printf("Are you sure to exit?N to cancel or the program will exit.\n");  
                    if(getch()=='N')  
                    {  
                        printf("Exit request cancelled!\n");  
                        break;  
                    }  
                    else   
                    {  
                        printf("Program end!\n");  
                        return 0;  
                    }  
                }  
            default:  
                printf("Warning!Error choose!\n\n");  
                break;  
        }  
    }  
    free(head);  
    head=NULL;  
    return 0;  
}  

struct Info* LinkList_create()  
{  
    int n,i;  
    struct Info* head=NULL;  
    struct Info* pf=NULL;  
    struct Info* pb=NULL;  
    printf("How many workers do you want to creat?\n");  
    scanf("%d",&n);
    for(i=0;i<n;i++);
    {  
        printf("Input the Infomation about this workers.\n");  
        pb=(struct Info*)malloc(sizeof(struct Info*));
        printf("\num:");        scanf("%d",&pb->num);
        printf("\name:");      scanf("%d",&pb->name);
        printf("\sex(male  or  female):");   scanf("%d",&pb->sex);
        printf("\birthday(yyyy/mm/dd):");   scanf("%d/%d/%d",&pb->birthday.year,&pb->birthday.month,&pb->birthday.day);
        printf("\education:");     scanf("%d",&pb->education);
        printf("\duty:");     scanf("%d",&pb->duty);
        printf("\wage");      scanf("%d",&pb->wage);
        printf("\address");   scanf("%d",&pb->addr);
        printf("\telphone");   scanf("%d",&pb->phone);  
        if(i==0)  
        {  
            head=pb;  
            pf=pb;  
        }  
        else  
        {  
            pf->next=pb;  
            pf=pb;  
        }         
    }  
    pb->next=NULL;  
    return head;  
}  

struct Info* LinkList_insert(struct Info *head)  
{  
    struct Info *newInfo;  
    struct Info *pf=head;  
    struct Info *pb=head;  
    newInfo=(struct Info*)malloc(sizeof(struct Info));  
    printf("\num:");        scanf("%d",&newInfo->num);
    printf("\name:");      scanf("%d",&newInfo->name);
    printf("\sex(male  or  female):");   scanf("%d",&newInfo->sex);
    printf("\birthday(yyyy/mm/dd):");   scanf("%d/%d/%d",&newInfo->birthday.year,&newInfo->birthday.month,&newInfo->birthday.day);
    printf("\education:");     scanf("%d",&newInfo->education);
    printf("\duty:");     scanf("%d",&newInfo->duty);
    printf("\wage");      scanf("%d",&newInfo->wage);
    printf("\address");   scanf("%d",&newInfo->addr);
    printf("\telphone");   scanf("%d",&newInfo->phone);  
    while(pb->num<=newInfo->num)  
    {  
        pf=pb;  
        pb=pb->next;  
        if(pb==NULL)  
            break;  
    }  
    pf->next=newInfo;  
    newInfo->next=pb;  
    return head;  
}  


void LinkList_display(struct Info* head)  
{  
    do  
    {  
        printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);        
    }while(head=head->next);  
}  
  
void linklist_delete(struct Info* head)  
{  
   char num[10];  
    struct Info* pf;  
    struct Info* pb;  
    pf=head;  
    pb=head;  
    printf("Which workers do you want to delete?");  
    printf("Input the num:");  
    scanf("%d",&num);  
    while(pb->num!=num)  
    {  
        pf=pb;  
        pb=pb->next;  
        if(pb==NULL)  
        {  
            printf("The inputed num doesn't exist!\n");  
            return ;  
        }  
    }  
    pf->next=pb->next;  
    printf("delete OK!\n");  
}  

void LinkList_find(struct Info* head)
{
    char num[10];  
    printf("Input the num to find ...\n");     
    scanf("%d",&num);  
    while(head->num!=num)  
    {  
        head=head->next;  
        if(head==NULL)  
        {  
            printf("the inputed num dosen't exist!");  
            return ;  
        }  
    }  
    if(head->num==num)  
        printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);
}

struct Info* LinkList_change(struct Info* head)  
{  
    char num[10];  
    struct Info* pf;  
    struct Info* pb;  
    pf=head;  
    pb=head;  
    printf("Which workers do you want to change?");  
    printf("Input the num:");  
    scanf("%d",&num);  
    while(pb->num!=num)  
    {  
        printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);
        pb=(struct Info*)malloc(sizeof(struct Info*));
        printf("\num:");        scanf("%d",&pb->num);
        printf("\name:");      scanf("%d",&pb->name);
        printf("\sex(male  or  female):");   scanf("%d",&pb->sex);
        printf("\birthday(yyyy/mm/dd):");   scanf("%d/%d/%d",&pb->birthday.year,&pb->birthday.month,&pb->birthday.day);
        printf("\education:");     scanf("%d",&pb->education);
        printf("\duty:");     scanf("%d",&pb->duty);
        printf("\wage");      scanf("%d",&pb->wage);
        printf("\address");   scanf("%d",&pb->addr);
        printf("\telphone");   scanf("%d",&pb->phone);  
        if(pb==NULL)  
        {  
            printf("The inputed num doesn't exist!\n");  
            return 1;  
        }  
    }  
    printf("change OK!\n");
    return head;
}  
搜索更多相关主题的帖子: 姓名 学历 college include doctor 
2013-01-06 11:42
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
struct Info* LinkList_change(struct Info* head)  
{  
    char num[10];  
    struct Info* pf;  
    struct Info* pb;  
    pf=head;  
    pb=head;  
    printf("Which workers do you want to change?");  
    printf("Input the num:");  
    scanf("%d",&num);  
    while(pb->num!=num)  
    {  
        printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);
        pb=(struct Info*)malloc(sizeof(struct Info*));
        printf("\num:");        scanf("%d",&pb->num);
        printf("\name:");      scanf("%d",&pb->name);
        printf("\sex(male  or  female):");   scanf("%d",&pb->sex);
        printf("\birthday(yyyy/mm/dd):");   scanf("%d/%d/%d",&pb->birthday.year,&pb->birthday.month,&pb->birthday.day);
        printf("\education:");     scanf("%d",&pb->education);
        printf("\duty:");     scanf("%d",&pb->duty);
        printf("\wage");      scanf("%d",&pb->wage);
        printf("\address");   scanf("%d",&pb->addr);
        printf("\telphone");   scanf("%d",&pb->phone);  
        if(pb==NULL)  
        {  
            printf("The inputed num doesn't exist!\n");  
            return 1;  
        }  
    }  
    printf("change OK!\n");
    return head;
}   
返回值要求是Info* 类型,你返回一个 int 类型,当然不行啦,return 0 或者 NULL 就行了。

你的代码不止上面的问题

1 转义字符问题 ,自己查下吧
2 申明和定义不一致
linklist_delete/ Linklist_delete
LinkList_creat / LinkList_create

你不发现不一样的吗

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-01-06 12:21
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9025
专家分:54030
注 册:2011-1-18
收藏
得分:0 
你在使用LinkList_create之前,没有定义它
你定义的是 struct Info* LinkList_creat(); 缺少一个e

在古老的已被废弃的C标准中,如果你没定义它,就把它当成一个返回类型为int的函数
所以你用标准的C编译器,如果没定义就使用,则即使不报错,也会给个警告信息
2013-01-06 12:23
星空下的雪
Rank: 1
等 级:新手上路
帖 子:13
专家分:9
注 册:2012-11-17
收藏
得分:0 
连接时为什么会出现这个???
--------------------Configuration: new  3(1) - Win32 Debug--------------------
Linking...
new  3(1).obj : error LNK2001: unresolved external symbol _LinkList_delete
Debug/new  3(1).exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

new  3(1).exe - 1 error(s), 0 warning(s)
2013-01-06 13:00
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
指明错误了你还找不到??注意我上面回复的 最后四行

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-01-06 13:41
快速回复:老出现struct Info *()' differs in levels of indirection from 'int ...
数据加载中...
 
   



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

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