gpt4 book ai didi

c编程gcc错误: assignment from incompatible pointer type [enabled by default]

转载 作者:行者123 更新时间:2023-11-30 20:11:15 24 4
gpt4 key购买 nike

我有以下功能

TreeNode* findParentNode(TreeNode *tn, int parentData, int branchSelect)
{
ListNode *temp1, *temp2;

if (tn->data == parentData)
{
if ((branchSelect == 0 && tn->left == NULL) || (branchSelect == 1 && tn->right == NULL))
return tn;
}
if (tn->left == NULL && tn->right == NULL)
return NULL;



temp1 = findParentNode(tn->left, parentData, branchSelect);
if (temp1 != NULL)
return temp1;

temp2 = findParentNode(tn->right, parentData, branchSelect);
if (temp2 != NULL)
return temp2;
}

该函数应返回父节点。
它在 vs 上运行良好,但是当我在 gcc 上运行它时,我收到上面的错误,我也需要它在 gcc 下工作,我读到了这个错误,但仍然没有找到修复它的方法。

some1 可以帮我修复它,以便我也可以在 gcc 上运行它吗?
提前致谢。

最佳答案

为什么不做

    ListNode *temp1, *temp2;

进入

    TreeNode *temp1, *temp2;

我不明白两者的定义是什么......

关于c编程gcc错误: assignment from incompatible pointer type [enabled by default],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41578720/

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