声明用C数组没有给大小 [英] Declaring an array in C without giving size
本文介绍了声明用C数组没有给大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在声明数组是这样的:
int array[][] = {
{1,2,3},
{4,5,6}};
我得到一个错误说:Array类型具有不完整的元素类型
I get an error saying: "Array type has incomplete element type"
这是怎么回事?
推荐答案
通过一个N维数组(N> 0),则需要定义N-1尺寸的大小;仅一个维度可以留为编译器来确定,并且它必须是第一维
With an N-dimensional array (N>0), you need to define the sizes of N-1 dimensions; only one dimension can be left for the compiler to determine, and it must be the first dimension.
您可以这样写:
int d1[] = { ... };
int d2[][2] = { ... };
int d3[][2][3] = { ... };
等
这篇关于声明用C数组没有给大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文