gpt4 book ai didi

c - 指针问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:19:02 26 4
gpt4 key购买 nike

我是 linux c 编程的新手,我有一个简单的程序只是为了学习,当我编译它时它给我错误“取消引用指向不完整类型的指针”这是我的代码

struct Node
{
struct Node* left;
struct Node* middle;
struct Node* right;
int nodeData;
int nodeLevel;
char isVisted;
};
struct ListNode
{
struct Node* data;
struct ListNode* next;
};

struct List
{
struct NodeList* head;
struct NodeList* tail;
int count;
};

typedef struct ListNode ListNode;
typedef struct Node Node;
typedef struct List List;

ListNode* InitListNode(Node* data)
{
ListNode* listNode=(ListNode*)calloc(1,sizeof(ListNode));
listNode->data=data;
listNode->next=NULL;
return listNode;
}

List* InitList()
{
List* list=(List*)calloc(1,sizeof(List));
list->count=0;
list->head=list->tail=NULL;
}

void EnQue(Node* data,List* que)
{
if(que->count==0)
{
que->tail=que->head=InitListNode(data);
que->count++;
}
else
{
que->tail->next=InitListNode(data); //here error is problem comes
que->tail=que->tail->next;//here error is problem comes
que->count++;
}
}

请帮忙..

最佳答案

struct List中的head和tail都是NodeList类型。应该是ListNode?

关于c - 指针问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3592618/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com