I am learning C++ using recommended C++ books. In particular, i read about std::istringstream
and saw the following example:
std::string s("some string");
std::istringstream ss(s);
std::string word;
while(ss >> word)
{
std::cout<<word <<" ";
}
Actual Output
some string
Desired Output
string some
My question is that how can we create the above std::istringstream
object ss
using the reversed string(that contains the word in the reverse order as shown in the desired output)? I looked at std::istringstream's constructors but couldn't find one that takes iterators so that i can pass str.back()
and str.begin()
instead of passing a std::string
.