input an array with a cin statement in a for loop

As a part of a larger project i need to be able to input an 2D array using a cin statement.
Code i have so far:
1
2
3
4
5
for(i=0; i < maxc; i++)
 for(j=0; j < maxr; j++)
  cout << "Please enter a integer for the array number: " << "[" << i << "]" 
        << "[" << j << "]" << endl;
  cin >> np[i][j];

^this just spams the cout statement without allowing any inputs.
I want the program to stop and allow the user to input a number for each individual cell ([0][0] , [0][1] , [0][2]...)
this just spams the cout statement without allowing any inputs.


You forgot the braces
1
2
3
4
5
6
7
8
9
for(i=0; i < maxc; i++)
{
 for(j=0; j < maxr; j++)
  {
cout << "Please enter a integer for the array number: " << "[" << i << "]" 
        << "[" << j << "]" << endl;
  cin >> np[i][j];
  }
}

Topic archived. No new replies allowed.