Why is my code not compiling?
I honestly have no idea what "invalid types of int[int] for array subscript" means...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <iostream>
using namespace std;
int magicSquare[3][3];
int row = 3;
int col = 3;
int RowSums;
int main()
{
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
magicSquare[row][col] = rand()%9;
cout << magicSquare[row][col] << " ";
}
cout << endl;
}
cout << "Row Check:" << endl;
for (row = 0; row < 3; row++) {
for (col = 0; col < 3; col++) {
RowSums[row] += magicSquare[row][col];
}
cout << " Row " << " sum: " << RowSums[row];
cout << endl;
}
return 0;
}
|
I suspect the issue is in line 31, where you say RowSums[row]
because above, you declare RowSums as an integer, not an integer array.
Thanks :)
Topic archived. No new replies allowed.