irritating error


keep getting three errors from this line


cout << nProduct[nRow][nCol] << "\t"<<endl;



void main ()
{

// Declare a 10x10 array

const int nNumRows = 10;

const int nNumCols = 10;

int nProduct[nNumRows ][nNumCols ] = { 0 };



// Calculate a multiplication table

for (int nRow = 0; nRow < nNumRows; nRow++)
{

for (int nCol = 0; nCol < nNumCols; nCol++)
{
nProduct[nRow][nCol] = nRow * nCol;
}

}


for (int nRow = 1; nRow < nNumRows; nRow++)

{for (int nCol = 1; nCol < nNumCols; nCol++)

{
cout << nProduct[nRow][nCol] << "\t"<<endl;
}

}

getch();
}
An array declared as a[10] has elements in the range of a[0] to a[9], a[10] is out of bounds. That's exactly what you're accessing, one beyond the array in each dimension.
Topic archived. No new replies allowed.