| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 710 人关注过本帖
标题:百度不出来的错误 'struct addr *(struct addr *,struct addr *)' diff ...
只看楼主 加入收藏
zuiyu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-9-22
收藏
 问题点数:0 回复次数:4 
百度不出来的错误 'struct addr *(struct addr *,struct addr *)' differs in levels of i
#include <stdio.h>
#include <stdlib.h>

struct addr{        //通讯录的结点
    char name[30];
    char street[40];
    char city[20];
    char state[3];
    char tel[11];
    struct addr *next;
};

struct addr *head,*start,*last;   //定义全局变量


int menu_select(){      
    char s[80];
    int c;
    printf("1_Enter a name\n");
    printf("2_Delete a record\n");
    printf("3_Search\n");
    printf("4_Quit\n");
    do{
        ptintf("\nEnter your choice:");
        gets(s);
        c=atoi(s);
    }while(c<1||c>4);                                    //如果做的不满意,返回继续做
    return (c);
}

void enter()
{
    struct addr *info;
    void inputs(char*,char*,int);
    int n;
    for(n=0;;n++)
    {
        info=(struct *)malloc(sizeof(struct addr));
        if(info==NULL)
        {
            printf("\nout of memory");
            return ;
        }
        
        inputs("enter name:",info->name,30);
        if(info->name[0]=='0')
            break;
        else{
        inputs("enter street:",info->street,40);            
        inputs("enter city:",info->city,20);
        inputs("enter state:",info->state,3);
        inputs("enter tel:",info->tel,11);
        start=des_store(info,start);
        if(n==0)
            head=start;
        }
    }
}


void inputs(char *pl,char *s,int count)                                    
{
    char p[40];
    do{
        printf("%s",pl);
        gets(p);
        if(strlen(p)>count)                                                   
            printf("\n too long\n");
    }while(strlen(p)>count);                                            
    strcpy(s,p);
}


struct addr* des_store(struct addr *i,struct addr *top)
{
    if(!last)
    {
        last=i;
        return i;
    }
    else{
        top->next=i;
        i->next=NULL;
        last=i;
        return i;
    }
}


struct addr *find(char *name)
{
    struct addr *info;
    info=head;
    while(info)
    {
        if(!strcmp(name,info->name))
            return(info);
        else
            info=info->next;
    }
    return(info);
}


void search()
{
    char name[40];
    struct adde *info;
    printf("enter name to find:");
    gets(name);
    if((info=find(name))==NULL)
        printf("not found\n");
    else{
        display(info);
    }
}


void deleted()
{
    char s[80];
    struct addr*pl,*p2,*info;
    printf("enter name:");
    gets(s);
    info=find(s);
    if(info!=NULL)
    {
        if(head==info)
        {
            head=info->next;
            printf("deleted:%d\n",info->name);
            free(info);
        }
        else{
            pl=head->next;
            while(info!=pl)
            {
                p2=pl;
                pl=pl->next;
            }
            p2->next=pl->next;
            printf("deleted:%s\n",info->name);
            free(info);
        }
    }
    else
        printf("%s not find!\n",info->name);
}







void main(){
    char s[80],choice;
    struct addr *info;
    start=last=NULL;            
    for(;;)                                                                    
        switch(menu_select())                                            //根据菜单返回的选项,进入不同的功能   
        {
            case 1:enter();
                break;
            case 2:deleted();
                break;
            case 3:search();
                break;
            case 4:exit(0);
        }
}
搜索更多相关主题的帖子: include 百度 levels 通讯录 choice 
2015-10-08 23:20
皇笉
Rank: 1
来 自:香港
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-10-10
收藏
得分:0 
没看懂

找呀找呀找朋友~,我是新手,请多指教
2015-10-11 21:30
the_second
Rank: 2
等 级:论坛游民
帖 子:115
专家分:80
注 册:2015-9-13
收藏
得分:0 
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct stud_node
{
    int num;
    char name[20];
    int score;
    struct stud_node *next;
};
struct stud_node *Create_Stu_Doc();
struct stud_node *InsertDoc(struct stud_node *head,struct stud_node *stud);
struct stud_node *DeleteDoc(struct stud_node *head,int num);
void Print_Stu_Doc(struct stud_node *head);

int main(void)
{
    struct stud_node *head,*p;
    int choice,num,score;
    char name[20];
    int size=sizeof(struct stud_node);
    do
    {
        printf("1:Create 2:Insert 3:Delete 4:Print 0:Exit\n");
        scanf("%d",&choice);
        switch(choice)
        {
            case 1:
                head =Create_Stu_Doc();
                break;
            case 2:
                printf("Input num,name and score:\n");
                scanf("%d%s%d",&num,name,&score);
                p=(struct stud_node *)malloc(size);
                p->num=num;
                strcpy(p->name,name);
                p->score=score;
                head=InsertDoc(head,p);
                break;
            case 3:
                printf("Input num:\n");
                scanf("%d",&num);
                head=DeleteDoc(head,num);
                break;
            case 4:
                Print_Stu_Doc(head);
                break;
            case 0:
                break;
               
        }
    }while(choice !=0);
    return 0;
}

//êy¾Y½á11
struct stud_node *Create_Stu_Doc()    //óÃêy¾Y½á11oˉêy£¬′′½¨½á11ê±£¬ÎTêäèë
{
    struct stud_node *head,*p;
    int num,score;
    char name[20];
    int size=sizeof(struct stud_node);
    head=NULL;
    printf("Input num,name and score:");
    scanf("%d%s%d",&num,name,&score);
    while(num!=0)
    {
        p=(struct stud_node *)malloc(size);
        p->num=num;
        strcpy(p->name,name);
        p->score=score;
        head=InsertDoc(head,p);
        scanf("%d%s%d",&num,name,&score);
    }
    return head;    //•μ»Ø½á11ìåμØÖ•
}

struct stud_node *InsertDoc(struct stud_node *head,struct stud_node *stud)
{
    struct stud_node *ptr,*ptr1,*ptr2;
    ptr2=head;
    ptr=stud;
    if(head==NULL)
    {
        head=ptr;
        head->next=NULL;
    }
    else
    {
        while((ptr->num>ptr2->num)&&(ptr2->next!=NULL))
        {
            ptr1=ptr2;
            ptr2=ptr2->next;
        }
        if(ptr->num<=ptr2->num)
        {
            if(head==ptr2)
                head=ptr;
            else
                ptr1->next=ptr;
            ptr->next=ptr2;
        }
        else
        {
            ptr2->next=ptr;
            ptr->next=NULL;
        }
    }
    return head;   
}

struct stud_node *DeleteDoc(struct stud_node *head,int num)
{
    struct stud_node *ptr1,*ptr2;
    while(head!=NULL&&head->num==num)
    {
        ptr2=head;
        head=head->next;
        free(ptr2);
    }
    if(head==NULL)
    {
        return NULL;
    }
    ptr1=head;
    ptr2=head->next;
    while(ptr2!=NULL)
    {
        if(ptr2->num==num)
        {
            ptr1->next=ptr2->next;
            free(ptr2);
        }
        else
        {
            ptr1=ptr2;
        }
        ptr2=ptr1->next;
    }
    return head;
}

void Print_Stu_Doc(struct stud_node *head)
{
    struct stud_node *ptr;
    if(head==NULL)
    {
        printf("\nNo Record\n");
        return;
    }
    printf("\nThe Students'Record Are:\n");
    printf("Num\t Name\t Score\n");
    for(ptr=head;ptr!=NULL;ptr=ptr->next)
    {
        printf("%d\t%s\t%d\n",ptr->num,ptr->name,ptr->score);
    }
}
2015-10-11 22:35
the_second
Rank: 2
等 级:论坛游民
帖 子:115
专家分:80
注 册:2015-9-13
收藏
得分:0 
这是我前不久打的
2015-10-11 22:36
hackrol
Rank: 4
来 自:世界和平组织
等 级:业余侠客
帖 子:62
专家分:267
注 册:2014-9-6
收藏
得分:0 
struct addr* des_store(struct addr *i,struct addr *top);  把这个声明放在最前面 .明显是未声明先使用了!
2015-10-11 22:49
快速回复:百度不出来的错误 'struct addr *(struct addr *,struct addr *)' ...
数据加载中...
 
   



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

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