PDA

View Full Version : Reading values from file to array



Jeo_
24th April 2009, 19:05
Hello!
I need to read values from text file.
Textfile looks like this:

a1 b20 c200 d125
a2 b20 c200 d125
a3 b20 c200 d125
a4 b20 c200 d125
...
a100 b20 c200 d125


And the code which I'm using:


(..load file to textstream in..)
int i=0;
do{
in>>line1>>line2>>line3>>line4;
! ! row1[i]=line1.remove(0,1).toInt(); !!
! ! row2[i]=line2.remove(0,1).toInt(); !!
! ! row3[i]=line3.remove(0,1).toInt(); !!
! ! row4[i]=line4.remove(0,1).toInt(); !!

i=i+1;

}while(!(line1.contains("STOP")));

It worked fine until I tried to save numbers to array. It prints number to screen but saving them to array dont work. Any ideas?

Jeo