0
#inlude <stdio.h>
typedef struct node
{
int data, height, count;
struct node *left, *right, *father;
}node;
node *root = NULL;
void main(){
//some code here
}
上面的代码没有给出错误,但为什么我不能将价值分配分成两个不同的陈述?
#inlude <stdio.h>
typedef struct node
{
int data, height, count;
struct node *left, *right, *father;
}node;
node *root;
root = NULL;
void main(){
//some code here
}
这将产生以下错误:
sample.c:11:1: error: conflicting types for 'root'
sample.c: 10:7 note: previous declaration of 'root' was here
node *root;
^
声明
root = NULL;
声明时,不转载上述错误在main function
可能是什么原因?
当函数不是初始化的一部分时,您不能只在函数之外分配一个变量。 –
请注意,所有全局变量都是零初始化的,将它们重新初始化为零就没有意义了。 –