ALL,
Here is my code:
std::string version = curl_version();
version = version.substr( version.find( '/' ) + 1 );
int min, max;
int pos = version.find( '.' );
std::stringstream stream( version.substr( 0, pos ) );
version = version.substr( pos + 1 );
stream >> max;
pos = version.find( '.' );
stream.str( version.substr( 0, pos ) );
stream >> min;
I’m just reusing the same stream object but for some reason min variable is not assigned properly.
What am I missing?
Thank you.
The problem is that you can’t reuse the same stringstream object, try doing like this instead:
It seems that when you shift (>>) out of a stringstream and it reaches eof (you can check by calling stream.eof()) a flag is set that prevents further shifting out even if you set (by calling str()) a new associated string object.
To make it work, you have to call clear() before shifting out again.