I've searched the web a bit and all I've come up with is "sprintf".
Also, for the converse, ie. string to double, is "atof" the way to go?
Kind Regards,
JKop
>What's the best method to use?
>I've searched the web a bit and all I've come up with is "sprintf".
Try the FAQ
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1
You can use a string stream.
ben
--
Richard Herring
> What's the best method to use?
>
> I've searched the web a bit
But apparently not the FAQ - usually a better place to start.
> and all I've come up with is "sprintf".
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1
> Also, for the converse, ie. string to double, is "atof" the way to go?
Again, a quick perusal of the FAQ would answer that:
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2
Best regards,
Tom
> What's the best method to use?
>
> I've searched the web a bit and all I've come up with is "sprintf".
>
> Also, for the converse, ie. string to double, is "atof" the way to go?
Boost libraries are a good choice for simple conversions. Look for
lexical_cast. sstream is a good choice for formatted strings. ex: int +
string + anotherint + anotherstring : "12 eggs is the same as 1 dozen
eggs."
For a comparison of boost::lexical_cast and the various other options,
see Herb Sutter's article:
http://www.gotw.ca/publications/mill19.htm
Cheers! --M