Linked Questions

140 votes
1 answer
98k views

stringstream parser; parser << 5; short top = 0; parser >> top; parser.str(""); //HERE I'M RESETTING parser parser << 6; //DOESN'T PUT 6 INTO parser short bottom = 0; parser >&...
There is nothing we can do's user avatar
119 votes
1 answer
111k views

ostringstream s; s << "123"; cout << s.str().c_str() << endl; // how to clear ostringstream here? s << "456"; cout << s.str().c_str() << endl; ...
Alex F's user avatar
  • 43.5k
106 votes
3 answers
88k views

How do I "reset" the state of a stringstream to what it was when I created it? int firstValue = 1; int secondValue = 2; std::wstringstream ss; ss << "Hello: " << firstValue; std::...
user974967's user avatar
  • 2,946
5 votes
3 answers
24k views

can any one tell me how to clear the content of the stringstream..? i tried the following but it didnt work. stringstream ss; ss<<"bala"<<"murugan"; cout<<ss.str(); //Output ...
Balamurugan's user avatar
  • 2,379
3 votes
1 answer
382 views

I was writing a code in C++ 11 that would read some lines and print the first word of each line. I decided to use getline and stringstream. string line, word; stringstream ss; while(somecondition){ ...
Ahsan Tarique's user avatar
0 votes
1 answer
250 views

At the moment I am storing some data into an output stream like so std::ostringstream oss; std::string fileData; for(int i = 0; i < 4; i++) { oss << i; fileData += oss.str(); } now ...
Canvas's user avatar
  • 5,915
1 vote
1 answer
122 views

Possible Duplicate: In C++, how do you clear a stringstream variable? I have a problem with a string i want to use to display in my loop. I set it up like this in my loop: //while { std::...
Sir's user avatar
  • 8,285
0 votes
0 answers
179 views

How do I clear a string stream. I am tokenizing a file line by line, and the stringstream is global. I can tokenize the first line, but I can't get the second line working stringstream currentLine; ...
Trent C's user avatar
  • 31
0 votes
0 answers
84 views

void fill() { ifstream fin; fin.open(File); if (!fin) { throw std::runtime_error("unable to open file"); } char line[maximumCodeLine]; std::stringstream stream; string letter; string code; while(...
kisung Tae's user avatar
122 votes
4 answers
61k views

I'd like to clear out and reuse an ostringstream (and the underlying buffer) so that my app doesn't have to do as many allocations. How do I reset the object to its initial state?
twk's user avatar
  • 17.4k
48 votes
5 answers
22k views

At 50:40 of http://channel9.msdn.com/Events/GoingNative/2013/Writing-Quick-Code-in-Cpp-Quickly Andrei Alexandrescu makes a joke about how not efficient/slow istream is. I had an issue in the past ...
user avatar
23 votes
7 answers
44k views

These threads do NOT answer me: resetting a stringstream How do you clear a stringstream variable? std::ifstream file( szFIleName_p ); if( !file ) return false; // create a string stream for parsing ...
Icebone1000's user avatar
  • 1,332
41 votes
1 answer
46k views

One of the possibilities is: somestringstream.str(""); But is it most optimal? Is there any way to preserve stringstream internal buffer, so that following operator<<() calls would not require ...
user avatar
6 votes
3 answers
11k views

std::ostream has no member function close(). What type of stream should I not be allowed to close? As an example, maybe I would like to close std::cout in order to prevent any further writing to it. ...
Brent Bradburn's user avatar
5 votes
2 answers
9k views

C++14 Generally, the staff in university has recommended us to use Boost to parse the file, but I've installed it and not succeeded to implement anything with it. So I have to parse a CSV file line-...
CCPPSup's user avatar
  • 51

15 30 50 per page