Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C组链表(抽象数据类型)_C_Struct_Linked List - Fatal编程技术网

C组链表(抽象数据类型)

C组链表(抽象数据类型),c,struct,linked-list,C,Struct,Linked List,我试图编写一个抽象数据类型,用链表表示整数项集 我收到以下错误: ERROR undeclared identifier 'linkedListSet' error #2152: Unknown field 'code' of '(incomplete) struct LinkedListSet'. 我觉得我必须打破一些函数、结构和指针的基本规则,但我真的搞不懂。下面是我的代码,注释了错误消息行 #include<stdio.h> #include<stdlib.h>

我试图编写一个抽象数据类型,用链表表示整数项集

我收到以下错误:

ERROR undeclared identifier 'linkedListSet'

error #2152: Unknown field 'code' of '(incomplete) struct LinkedListSet'.
我觉得我必须打破一些函数、结构和指针的基本规则,但我真的搞不懂。下面是我的代码,注释了错误消息行

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

struct linkedListElement{
    int data;
    struct linkedListElement * next;
};

struct linkedListSet {
    //struct linkedListElement * firstElement;
    struct linkedListElement * header;
    struct linkedListElement * current;
    struct linkedListElement * temp;
    int code;
};

struct linkedListSet * createdSet (){
    struct linkedListSet * newSet = malloc(sizeof(linkedListSet));
    //ERROR undeclared identifier 'linkedListSet'

    newSet->header->data = 0;
    newSet->header->next = NULL;

    return newSet;
}

int addItem (struct LinkedListSet * setPtr, int info){
    struct linkedListElement * newElementPtr;

    setPtr->code = 3;
    //error #2152: Unknown field 'code' of '(incomplete) struct LinkedListSet'.
    return 1;
};

int main(){
    return (0);
#包括
#包括
结构链接列表元素{
int数据;
结构linkedListElement*下一步;
};
结构链接列表集{
//结构linkedListElement*第一个元素;
结构linkedListElement*头;
结构linkedListElement*当前;
结构linkedListElement*temp;
int代码;
};
结构linkedListSet*createdSet(){
结构linkedListSet*newSet=malloc(sizeof(linkedListSet));
//未声明标识符“linkedListSet”时出错
新闻集->标题->数据=0;
新闻集->标题->下一步=空;
返回新闻集;
}
int addItem(结构链接列表集*setPtr,int info){
结构linkedListElement*newElementPtr;
setPtr->code=3;
//错误#2152:结构LinkedListSet'的未知字段“代码”。
返回1;
};
int main(){
返回(0);

linkedListSet
应该是
struct linkedListSet

struct linkedListSet * newSet = malloc(sizeof(struct linkedListSet));
LinkedListSet
应该是
LinkedListSet

int addItem (struct linkedListSet * setPtr, int info)

尝试这样引用结构

typedef struct /* my struct tag */ {
int a;
int b;
} MyStructType;
后来

MyStructType * mystruct;
mystruct->a = 34;
// etc...

非常感谢-基本错误,但我根本看不到!