vico
vico

Reputation: 18251

get everything from stringstream

I have placed som information to stringstream ss:

stringstream ss (stringstream::in | stringstream::out);
ss<<"abc 456 ";
ss<<123

Then I decided to retrieve string content to string g:

std::string s;
std::string g;

for (int n=0; n<c; n++)
{
ss >> s;
g=g+s;
}
cout << g <<endl;

For this reason I need to know how many placements was done to ss. How to know that? Probably method that retrieves string information is not very clever - then give your way.

Upvotes: 0

Views: 503

Answers (1)

Doug T.
Doug T.

Reputation: 65649

I need to know how many placements was done to ss. How to know that?

You'll need to count this yourself, stringstream provides no ability to count how many insertions were done to it.

Probably method that retrieves string information is not very clever - then give your way.

How about:

ss.str()

To get the full string with everything thats been inserted into it.

Upvotes: 6

Related Questions