By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

[iostream] how to get the rest string of a istream

P: n/a
mos
Hi!

the question can describle as code:

//os like "mike head hello world!"
string GetRest(istringstream& os)
{
string name,part; //and maybe some other element
os >> name >> part;
//do something...

ostringstream stream2;
stream2 << stream.rdbuf();
return stream2.str()
}

I just want the rest of os ("hello world!"), but my method seems ugly, is
there a graceful way?

thanks in advance.

jiang.yu

Jun 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mos wrote:
Hi!

the question can describle as code:

//os like "mike head hello world!"
string GetRest(istringstream& os)
{
string name,part; //and maybe some other element
os >> name >> part;
//do something...

ostringstream stream2;
stream2 << stream.rdbuf();
return stream2.str()
}

I just want the rest of os ("hello world!"), but my method seems ugly, is
there a graceful way?
Take a string as input, search for the second blank space, and retrieve
the substring.

Ben

thanks in advance.

jiang.yu

Jun 24 '06 #2

P: n/a
mos
Hi!
Your answer not satisfy me.
How do I know it is the second black space, may be '\t', may be '\n'
And I want to general way to get the rest of a istream.

jiang.yu

"benben" <be******@yahoo.com.au>
??????:44***********************@news.optusnet.com .au...
mos wrote:
Hi!

the question can describle as code:

//os like "mike head hello world!"
string GetRest(istringstream& os)
{
string name,part; //and maybe some other element
os >> name >> part;
//do something...

ostringstream stream2;
stream2 << stream.rdbuf();
return stream2.str()
}

I just want the rest of os ("hello world!"), but my method seems ugly,
is there a graceful way?


Take a string as input, search for the second blank space, and retrieve
the substring.

Ben

thanks in advance.

jiang.yu


Jun 26 '06 #3

P: n/a
"mos" <mm*******@163.com> wrote in message
news:e7**********@news.cn99.com...
Hi!
Your answer not satisfy me.
How do I know it is the second black space, may be '\t', may be '\n'
And I want to general way to get the rest of a istream.

jiang.yu

"benben" <be******@yahoo.com.au>
??????:44***********************@news.optusnet.com .au...
mos wrote:
Hi!

the question can describle as code:

//os like "mike head hello world!"
string GetRest(istringstream& os)
{
string name,part; //and maybe some other element
os >> name >> part;
//do something...

ostringstream stream2;
stream2 << stream.rdbuf();
return stream2.str()
}
You could just return istringstream& and let whatever calls it get them
itself.
I just want the rest of os ("hello world!"), but my method seems ugly,
is there a graceful way?


Take a string as input, search for the second blank space, and retrieve
the substring.

Ben

thanks in advance.

jiang.yu

Jun 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.