Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

File reading problem

$
0
0
Basically, why is
in.ignore('v');
in.ignore(' ');
sscanf(c,"%f %f %f",&f1,&f2,&f3);



not the same as
sscanf(c,"v %f %f %f",&f1,&f2,&f3);



when reading the line (from file)
v 0.467854 0.394649 -1.000000



The 1st code does not work, while the 2nd does work. Why does the 1st code not work?


According the documentation, ifstream::ignore will remove characters until it finds the argument('v', for example), and also remove the argument('v'), so the two codes should work the same, right?

Documentation:
istream&  ignore ( streamsize n = 1, int delim = EOF );

Extracts characters from the input sequence and discards them.
 
The extraction ends when n characters have been extracted and discarded or when the character delim is found, whichever comes first. In the latter case, the delim character itself is also extracted.


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>