chhgk1995 2015-10-17 14:14 采纳率: 100%
浏览 3267
已采纳

c语言编译 出现error C2061 和error C2059

图片说明

不知道为什么一直出现说我标识符有问题的提示,我看了下以前编的程序,好像也是这样写法的啊,不知这次怎么会这样。求各位大神相助。

 #include <stdio.h>
#include <stdlib.h> 

struct Jihe{
    char nodeSet;
    struct Jihe* next;
};

bool Initiate(struct Jihe** head){
    *head = (struct Jihe*)malloc(sizeof(struct Jihe));
    (*head)->next = NULL;
    return 1;
}

bool RecordSet(struct Jihe* head,char text[]){
    struct Jihe* set = head;
    int i = 0;
    while(text[i] != '\0'){
        set->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        set->next->nodeSet = text[i];
        i++;
        set = set->next;
    }
    set->next = NULL;
    RankSet(&head);
    return 1;
}

bool GetAnd(struct Jihe* head1,struct Jihe* head2,struct Jihe** result){
    struct Jihe *set1 = head1,*set2 = head2,*set3 = *result;
    while(set1->next != NULL && set1->next->next != NULL){
        set3->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        set3->next->nodeSet = set1->next->nodeSet;
        set3 = set3->next;
        set1 = set1->next;
    }
    while(set2->next->next != NULL){
        set3->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        set3->next->nodeSet = set2->next->nodeSet;
        set3 = set3->next;
        set2 = set2->next;
    }
    set3->next = NULL;
    RankSet(result);
    return 1;
}

bool GetCross(struct Jihe** head1,struct Jihe** head2){
    return 1;
}

bool GetDiffer(struct Jihe** head1,struct Jihe** head2){
    return 1;
}

bool RankSet(struct Jihe** head){
    char rankSet[20] = {0};
    int i = 0 ,j = 0,len = 0;//len记录集合大小
    int small = 0, move;//move是用来删除元素的;
    char temp;
    struct Jihe* set = *head;
    struct Jihe* newSet = NULL;
    if(set == NULL){
        printf("空链表\n");
        return 0;
    }
    while(set->next != NULL && set->next->next != '\0'){
        rankSet[i] = set->next->nodeSet;
        set = set->next;
        len++;
    }

    for(i = 0;i < len; i++){
        for(j = i+1;j < len;j++){
            //删除子串中相同的元素
            if(rankSet[i] == rankSet[j]){
                //当这个元素为最后一个时,将终止符前移
                for(move = j; move <= len-1; move++){
                    rankSet[move] = rankSet[move+1]; 
                }
                len--;
            }
            if((rankSet[small] > rankSet[j]) && rankSet[j] != '\0' )
                small = j;
        }
        if(rankSet[small] == '\0')
            break;
        temp = rankSet[small];
        rankSet[small] = rankSet[i];
        rankSet[i] = temp;
    }
    newSet = (struct Jihe*)malloc(sizeof(struct Jihe));
    head = &newSet;
    for(i = 0;i < len;i++){
        newSet->next = (struct Jihe*)malloc(sizeof(struct Jihe));
        newSet->next->nodeSet = rankSet[i];
        newSet = newSet->next;
    }
    newSet->next = NULL;
    return 1;
}

bool GetSet(struct Jihe* head,char nowSet[]){
    struct Jihe*p = head;
    int i = 0;
    nowSet = {0};
    while(p->next != NULL && p->next->next != NULL){
        nowSet[i] = p->next->nodeSet;
        p = p->next;
        i++;
    }
    return 1;
}





void main(){
    struct Jihe *set1;
    struct Jihe *set2;
    struct Jihe *result;
    char text[20] = {0};
    Initiate(&set1);
    Initiate(&set2);
    Initiate(&result);
    printf("Set1 = :");
    scanf("%s",text);
    RecordSet(set1,text);
    printf("Set2 = ");
    scanf("%s",text);
    RecordSet(set2,text);
    printf("Set1 ∪ Set2 = ");


}
  • 写回答

2条回答

  • chhgk1995 2015-10-18 06:55
    关注

    返回类型不行。或许是c语言没有bool型(忘了到底有没有了),该为int就没事了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多