用C int数组的初始值 [英] initial value of int array in C
问题描述
在声明C中的数组是这样的:
When declaring an array in C like this:
int array[10];
什么是整数的初始值Δα我收到不同的编译器不同的结果,我想知道有没有什么做的编译器或操作系统。
What is the initial value of the integers?? I'm getting different results with different compilers and I want to know if it has something to do with the compiler, or the OS.
推荐答案
如果数组是在函数中声明,则该值是不确定的。 INT X [10];
函数中的意思是:取memroy的10-INT-大小面积的所有权没有做任何初始化。如果数组被声明为一个全球性或函数中的静态
,那么所有元素都初始化为零,如果他们尚未初始化。
If the array is declared in a function, then the value is undefined. int x[10];
in a function means: take the ownership of 10-int-size area of memroy without doing any initialization. If the array is declared as a global one or as static
in a function, then all elements are initialized to zero if they aren't initialized already.
这篇关于用C int数组的初始值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!