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

istringstream problem

$
0
0
When i try to read this line from a file ->
usemtl 0.298_0.802__0.800



And try to extract the 3 float values from the string, i get the following output:
0.298 0.802 -1.07374e+008



Which you can see works fine, until it reaches the last float value.

This can be tested using the following function:
void foo(){
	std::istringstream instream;
	string s = "usemtl 0.298_0.802__0.800";
	float f1,f2,f3;
	instream.str(s);
	string trash = "usemtl";
	char c = '_';
	instream >> trash >> f1 >> c >> f2 >> c >> f3;
	cout << f1 << " " << f2 << " " << f3 << endl;
	instream.clear();
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



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