我正在尝试编写一个抽象数据类型来表示使用链表的整数项集。
我收到以下错误:
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);