If i wanted to save entire input till EOF into 1 string, any idea how I would do this?
(besides getline and concating strings every time, thats the only solution I can think of)
Thanks
Printable View
If i wanted to save entire input till EOF into 1 string, any idea how I would do this?
(besides getline and concating strings every time, thats the only solution I can think of)
Thanks
Given a std::istream named in, one way is:
But I recall from an old thread that a more efficient method works along the lines of what you have described. Perhaps you can search and find out what exactly was the most efficient method we considered.Code:std::stringstream ss;
ss << in.rdbuf();
std::string str = ss.str();
Try to keep things simple. If getline works fine in your situation, leave the alternate. Making things complex for yourself will reap no benefits. Curiosity however is fine and a good thing.