istringstream

C++ problem with string stream istringstream

I am reading a file in the following format 1001 16000 300 12.50 2002 24000 360 10.50 3003 30000 300 9.50 where the items are: loan id, principal, months, interest rate. I'm not sure what it is that I am doing wrong with my input string stream, but I am not reading the values correctly because only the ...

C++ - repeatedly using istringstream

I have a code for reading files with float numbers on line stored like this: "3.34|2.3409|1.0001|...|1.1|". I would like to read them using istringstream, but it doesn't work as I would expect: string row; string strNum; istringstream separate; // textovy stream pro konverzi while ( getline(file,row) ) { separate.str(r...

Extracting bool from istream in a templated function

I'm converting my fields class read functions into one template function. I have field classes for int, unsigned int, long, and unsigned long. These all use the same method for extracting a value from an istringstream (only the types change): template <typename Value_Type> Value_Type Extract_Value(const std::string& input_string) { ...

non-copying istringstream

So istringstream copies the contents of a string when initialised, e.g string moo("one two three four"); istringstream iss(moo.c_str()); I was wondering if there's a way to make std::istringstream use the given c_str as its buffer without copying things. This way, it wont have to copy large bits of memory before passing the std::istri...

What's the difference between istringstream, ostringstream and stringstream? / Why not use stringstream in every case?

Hello, I think the title says pretty much everything, hehe. I would like you to tell me when to use std::istringstream, std::ostringstream and std::stringstream and why I shouldn't just use std::stringstream in every scenario (like are there any runtime performance issues?). Thanks! PS: I have a third, less important question. Is ther...