hi, i want to read float data from a .txt file, and i'm having problems doing it. The file seems something like this :
the number of columns in it is variable, the number of lines is always the same (45 - actually it is 15*3 , since these data are coordinates of a 3dimensional image). I got a matrix as follows to store the data :
so the problem comes when i'm trying to take the data of one line. I don't know how to get them, since the number of columns is not constant (NUM_S). I was trying to use 'getline' but i didn't manage to make it work properly ( it was impossible to convert char to float). My question is : how could i detect where the end of line is????
i got something like this ( i know, it's nothing for now, but i can't figure out how to get what i want, and what i need
please, help me!!!! i'll be completely grateful for life
Code:
233.6 163.5 291.0 228.5 252.3 259.2 232.1 318.5 251.4
.1 60.6 736.1 354.1 106.6 1154.7 261.1 165.5 1499.4
9 344.2 289.5 153.0 305.7 288.5 242.5 275.2 289.9
.4 349.5 57.2 718.7 389.1 109.0 1141.0 497.6 152.3
5 227.6 96.8 353.2 229.4 164.0 315.8 224.2 252.6....
....
....
the number of columns in it is variable, the number of lines is always the same (45 - actually it is 15*3 , since these data are coordinates of a 3dimensional image). I got a matrix as follows to store the data :
Code:
float coord[NUM_P][2][NUM_S];
//NUM_P=44,NUM_S=number of samples, it depends on the file given
so the problem comes when i'm trying to take the data of one line. I don't know how to get them, since the number of columns is not constant (NUM_S). I was trying to use 'getline' but i didn't manage to make it work properly ( it was impossible to convert char to float). My question is : how could i detect where the end of line is????
i got something like this ( i know, it's nothing for now, but i can't figure out how to get what i want, and what i need
Code:
rfile.open("ima1.txt");
while(!rfile.eof())
{
rfile>>f;
}
please, help me!!!! i'll be completely grateful for life