C固定阵列初始化 - 如何详细,我需要是什么? [英] C Static Array Initialization - how verbose do I need to be?
本文介绍了C固定阵列初始化 - 如何详细,我需要是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要初始化的都是零一个int数组,做我需要使用:
INT foo的[10] = {0,0,0,0,0,0,0,0,0,0};
或者,将这项工作:
INT富[10] = {0};
解决方案
INT富[10] = {0};
这是非常精细:)
请注意,如果你做到以下几点:
INT富[10] = {1};
只有阵列的第一个元素将与非零数进行初始化,而其余部分将用零来初始化。
To initialize an int array with all zeros, do I need to use:
int foo[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
Or, will this work:
int foo[10] = {0};
解决方案
int foo[10] = {0};
This is very fine :)
Note that if you do the following:
int foo[10] = {1};
Only the first element of the array will be initialized with the non-zero number whereas the rest will be initialized with zeros.
这篇关于C固定阵列初始化 - 如何详细,我需要是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文