#include<stdio.h>
#include<stdlib.h>
typedef struct //create a pointer structure
{
int data;
struct node *left;
struct node *right;
} node;
node *insert(node *root, int x);
//Insert Function
node *insert(node *root, int x) //Line 53
{
if(!root)
{
root = new_node(x);
return root;
}
if (root->data > x)
{
root->left = insert(root->left, x); //Line 63
}
else
{
root->right = insert(root->right, x); // Line 68
}
return root;
}
编译时出现以下错误:
:在函数'insert'中:
:63:3:警告:从不兼容的指针类型[默认启用]传递'insert'的参数1
:53:7:注意:预期'struct node *'但参数类型为'struct node *'
:63:14:警告:从不兼容的指针类型[默认启用]
进行分配:68:3:警告:从不兼容的指针类型[默认启用]传递'insert'的参数1
:53:7:注意:预期'struct node *'但参数类型为'struct node *'
:68:15:警告:从不兼容的指针类型[默认启用]
进行分配
答案 0 :(得分:0)
将结构定义更改为
struct node //create a pointer structure
{
int data;
struct node *left;
struct node *right;
};
和函数原型
struct node *insert(struct node *root, int x);