c - 指针问题

标签 c linux

我是 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/

相关文章:

c - 从 C 中的变量构建字符串

linux - Linux内核中ASID用完了怎么处理?

c - 如果我只有设备缓冲区 (PCIe) 的物理地址,我该如何将此缓冲区映射到用户空间?

linux - 为什么我的 Linux vps 的内存使用很多?

c++ - 执行结束时出现段错误(核心转储)

iphone - 多操作系统与SIngle OS电话和服务器开发

c++ - 如何使用棋盘找到两个摄像机之间的旋转/平移

c - OpenMp和代码块16?

c - Malloc 和结构

c - 从 lua 调用 c 函数比从 c 调用更快吗?