See the N3242 Working Draft of C++11, chapter 21.5 Numeric Conversions.
There are some useful functions, such as string to_string(int val);
mentioned but I don't understand how they're called. Can anyone give me an example please?
Those functions are in the header <string>
. You just call them like any other function:
#include <string>
std::string answer = std::to_string(42);
GCC 4.5 already supports those functions, you just need to compile with the -std=c++0x
flag.
Sure:
std::string s = std::to_string(123); // now s == "123"
These functions use sprintf
(or equivalent) internally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With