M
Markus Kern
Hi!
I want to do what has been tried before
by many: Converting a string into an integer
*the C++ way* (= using streams rather than atoi).
Knowing I'm not the first to wonder how, I
googled getting this solution only:
-----------------
int number;
string test = "1234";
istringstream buf(test);
buf >> number;
-----------------
However, what I want to do is to use buf *after*
defining test --or at least, after assing any
value to test, so something like:
-----------------
int number;
string test;
istringstream buf;
test="1234";
// and now turn "test" into an
// integer, maybe something like:
// buf(test) >> number;
// or
// buf=test; buf >> number;
------------------
Oh, BTW, I *have* read http://www.parashift.com/cpp-faq-lite/
Thanks for any suggestions in advance
M.K.
I want to do what has been tried before
by many: Converting a string into an integer
*the C++ way* (= using streams rather than atoi).
Knowing I'm not the first to wonder how, I
googled getting this solution only:
-----------------
int number;
string test = "1234";
istringstream buf(test);
buf >> number;
-----------------
However, what I want to do is to use buf *after*
defining test --or at least, after assing any
value to test, so something like:
-----------------
int number;
string test;
istringstream buf;
test="1234";
// and now turn "test" into an
// integer, maybe something like:
// buf(test) >> number;
// or
// buf=test; buf >> number;
------------------
Oh, BTW, I *have* read http://www.parashift.com/cpp-faq-lite/
Thanks for any suggestions in advance
M.K.