Hi,
I'm trying to read from a file a char for time (that are float eg line of file: 1.1 1.0 3);
vector <vector <float> > example;
char ch;
string s;
int i=0,j=0;
while (f.readChar(ch)) { //this is my function return a char on ch
cout.put(ch);
if (ch == '\n') lines++;
else if (ch != ' ') {
s += ch;
} else {
example[i][j] = atof(s.c_str()); //but here a runtime error uccurs
s="";
j++;
}
i++;
}
vector <vector <float> > example;
char ch;
string s;
int i=0,j=0;
while (f.readChar(ch)) { //this is my function return a char on ch
cout.put(ch);
if (ch == '\n') lines++;
else if (ch != ' ') {
s += ch;
} else {
example[i][j] = atof(s.c_str()); //but here a runtime error uccurs
s="";
j++;
}
i++;
}
To copy to clipboard, switch view to plain text mode
How to do that conversion? And then: is this the easier way to reach my aim? (I suspect it can be more simple).
thanks
Bookmarks