For reference: http://cboard.cprogramming.com/showthread.php?t=53945
Well since using stringstream was mentioned I decided to take a look into it. For outputing the stuff its wonderful. A template function and an overloaded function and everything is covered.
As usual outputting seems to be 100 easier then inputting.
The problem I'm having is getting the characters that have been used removed from the string.
I tried str.str() which should return the stream's internal buffer per http://www.cplusplus.com/ref/iostrea...tream/str.html but I always get back nothing.Code:#include <sstream> #include <iostream> #include <string> int main() { using namespace std; string s = "134729l192.23839"; istringstream str(s); int x, z; char y; str>>x; str>>y; str>>z; cout<<x<<endl<<y<<endl<<z<<endl; //Not sure what to do here to get the following to display ".23839" cout<<s<<endl; }
From the testing I've done and the reading I've done it appears that it has the some "frailties" as cin (which I guess I should expect since stringstreams are deivered from the same base).
Also another quicky question to confirm my observation. Onceany changes made to s do not affect str until sync() is called correct?Code:string s = "134729l192.23839"; istringstream str(s);