I have a file:
P 0.5 0.6 0.3 30 300 80 150 160 400 200 150 250 300 T r 45 0 0 s 0.5 1.5 0 0 t 200 –150 . . .
When I read in \'P\' I know that
user to read text file line by line and then run string word;
ifstream fin(your file) while(! fin.eof()) { string line = fin.getline(); istringstream iss(line, istringstream::in); string token; while( iss >> token) { if (token.compare("T")) { ... } else { float f = atof(token.c_str()); } } }