dear all, being a starter with C++, i am getting a problem with array.
i have a (say),NxN array in a file, from which i have to read the nXn
(n<N, obviously) chunk, and with each iteration, the size will
increase. the first problem of dynamic allocation is solved. but i am
getting a trouble that the code is reading first nxn element along row
and not the chunk. suppose i have a array:
Quote:
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 0
|
and if i write the code
Code:
int main() {
ifstream infile ;
infile.open("file", ios::in);
const unsigned row = 4 ; // number of rows of the matrix, does not
match the row of file
const unsigned column = 3 ; // number of columns of the matrix;does
not match the column of file
// float matrix[row][column] ;
int Matrix[row][column-1] ;
for(int ii = 0; ii < row; ++ii) {
for(int jj = 0; jj < column; ++jj) {
infile >> Matrix[ii][jj] ;
cout << Matrix[ii][jj] << " " ;
}
cout << "\n" ;
}
return 0 ;
}
then we get the output:
where i am intending it should give
will you people plz help me?