"Medi Montaseri" <mo*******@netscape.net> wrote in message
news:c9**************************@posting.google.c om...
Given a stringstream object (tokens) containing
tokens << "token1 token2 token3 token4"
I'd like to extract the first token, which I do by saying
tokens >> token ; // where token is a string
And then pass the remaining portion down to a function.
If I just pass the tokens (even after removing one item from it)
to my function, I see that the entire payload is passed down.
How do I pass the remaining portion down to a function ?
ie "token2 token3 token4"
It would be better if you posted *compilable* code,
so we know for sure what's wrong.
Example:
#include <iostream>
#include <sstream>
void foo(std::stringstream& ss)
{
std::string tok;
while(ss >> tok)
std::cout << tok << '\n';
}
int main()
{
std::stringstream tokens("token1 token2 token3 token4");
std::string token;
tokens >> token;
foo(tokens);
return 0;
}
Output:
token2
token3
token4
HTH,
-Mike