As the title, how could I read different length of data into 2d array? And I know the upper limit of data length for each line. like..
5 6 9 8 4
5 4 9 5 6 5
1 2 3
4 5
I want to input these data into each row of 2d array, but c++'s cin will skip the input which is '\n'
so the method below doesn't work
for(int i=0; i<m; i++)
{
int ch=0;
while( (cin >> ch)!='\n' )
{
element[i][ch] = true;
}
}
so, how could I fix this? or, how could I distinguish '\n'? to let my "while" know that . thx a lot.