kostiak
kostiak

Reputation: 6541

Working with string streams?

Say i have a stringsteam in C++, and I want to do different operations to it like:

Searching for a sequence of characters, Converting block of text into int (in the middle of the line), Moving the get pointer back and forth and so on.

What is the standard/common way of doing this kind of things with stringstreams?

Upvotes: 3

Views: 659

Answers (2)

Ikke
Ikke

Reputation: 101261

As the name is saying, stringtream is a stream. A stream allows for sequential access, not random access. If you want random access, you can use the stringstream::str() function to get the string version of the string.

Upvotes: 3

Donotalo
Donotalo

Reputation: 13035

You can use stringstream::str() method which returns the associated std::string object. Then you can do your desired operations on the returned string.

Upvotes: 5

Related Questions