I've been scratching my head over this one for a bit. I've looked around and various references, articles, tutorials, etc. but I can't seem to find an effective solution.
I'm outputting a series of information using stringstreams to easily generate strings with number values. Simple enough. I can't seem to get the stringstream cleared so I can use it again for a new operation. This is the code that I have and I just know that there's a more effective way to handle this:
Declaring a new stringstream object every time I want a new bit of information can't possibly be an effective way of doing this and it looks truly ridiculous when I have 10 or 12 different strings I'm trying to output in the same function. Not to mention the maintenance headache.
stringstream tmpStr, tmpStr2;
tmpStr << "Some data";
tmpStr2 << "Some data 2";
drawText(mTestFont, tmpStr.str().c_str(), 0, 0);
drawText(mTestFont, tmpStr2.str().c_str(), 0, 20);
I've tried using the clear() and seekg(0, ios::beg) functions but haven't had any luck. I simply end up with the original string with the string tacked onto the end of it.
What's the appropriate way to properly clear/flush a string stream so that I can use it again with a 'blank slate' so to speak?