Two-Dimensional Array
For some reason every time I run this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
int main()
{
int arrey[2][3] =
{
{1, 2, 3},
{11, 12, 13},
{21, 22, 23}
};
for(int row; row < 2; row++)
{
for(int col; col < 3; ++col)
cout << arrey[row][col] << "\t";
cout << endl;
}
system("PAUSE");
return 0;
}
| |
I get this error
|
1>c:\users\will\desktop\book\main.cpp(10) : error C2078: too many initializers
| |
That's a 3x3 array, not 2x3.
You can also omit the sizes: int arrey[][]
Thanks
Topic archived. No new replies allowed.