read file and fill 2D array Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
Rachel
Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Jun 18, 2011 11:37 pm

read file and fill 2D array

Post by Rachel »

I have a problem with filling my array correctly and using the contents of the array...

my text file: 1 2 3 4 5 6 7 8

int col = 2;
int row = 4;
double matrix[row][col];
ifstream f("Data.txt");
f >> row >> col;
for (int j = 0; j < row; j++){
for (int i = 0; i < col; i++){
f >> matrix[j] ;
}
}
f.close();


afterwards I want to use the contents on my GUI, for example with:
(*WxEdit1) << matrix [1][1];

But the matrix is everywhere 0.00.
What am I doing wrong?
Rachel
Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Jun 18, 2011 11:37 pm

Re: read file and fill 2D array

Post by Rachel »

haha, just remove "f >> row >> col;" and everything is fine. I was confused..
Post Reply