Input two dimensional array

HI. I want to input the elements of a two dimensional array in the same line .
so while giving input . when i press enter . it should remain on the same line ?
HOW to do that ?
Thanks in advance.
I think this is what you're looking for.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

using namespace std;

int main(){
    const int X = 10, Y = 10;
    // I've made the array hold char. Change it to whatever type you want.
    char array_2d[X][Y]; 

    for(int i = 0; i < Y; i++){
        for(int j = 0; j < X; j++){
            cout << "Enter value for position " << j << ", " << i << ": ";
            cin >> array_2d[j][i];    
        }            
    }  

    return 0;
}
Topic archived. No new replies allowed.