本文介绍了C ++ - 数组的初始化程序太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个这样的数组,但它不断说我有太多的初始化。如何解决此错误?
I have made an array like this but then it keeps saying I had too many initializers. How can I fix this error?
int people[6][9] = {{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0}};
推荐答案
这里的问题是,
通常在声明一个多维数组时,第一个索引是行,第二个是列。
Normally when declaring a multi-dimensional array, first index is for rows, second is for columns.
此表单应修复此问题:
int people[9][6] = {{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0}};
这篇关于C ++ - 数组的初始化程序太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!