P
Poldanziern
Is there such a thing in C++ as stream which you can pass data into
and then retrieve data out of on the other end (without interacting
with the user or a file)?
For example, I'd like to extract a bunch of numbers, separated by
whitespace from a string ... say for example:
mystring = "100 2.0 666 3.14";
I realize that if the string contained only one number, I could use
atoi(). If it was reading in from a file, I could use myfilestream >>
a >> b >> c >> d;.
So basically I'm wondering if there's such a thing as a type of stream
object such that I could feed such a string into on one end and then
extract the variables out of the other end.
Like this:
stream mystream;
mystream << mystring;
mystream >> a >> b >> c >> d;
I know I could achieve this by streaming it out to a file and then
streaming it back in; I just want to know if there's a way to skip the
middle stage.
-Keith
and then retrieve data out of on the other end (without interacting
with the user or a file)?
For example, I'd like to extract a bunch of numbers, separated by
whitespace from a string ... say for example:
mystring = "100 2.0 666 3.14";
I realize that if the string contained only one number, I could use
atoi(). If it was reading in from a file, I could use myfilestream >>
a >> b >> c >> d;.
So basically I'm wondering if there's such a thing as a type of stream
object such that I could feed such a string into on one end and then
extract the variables out of the other end.
Like this:
stream mystream;
mystream << mystring;
mystream >> a >> b >> c >> d;
I know I could achieve this by streaming it out to a file and then
streaming it back in; I just want to know if there's a way to skip the
middle stage.
-Keith