hi,
in c there is a way of getting a unsigned long long into a char array by using sprintf, is there a method in c++ that gets an ull into a string?
thx
This is a discussion on unsigned long long to string conversion within the C++ Programming forums, part of the General Programming Boards category; hi, in c there is a way of getting a unsigned long long into a char array by using sprintf, ...
hi,
in c there is a way of getting a unsigned long long into a char array by using sprintf, is there a method in c++ that gets an ull into a string?
thx
stringstream - but I thought you weren't supposed to use C++?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
how do u use it?
unsigned long long input;
stringstream ss;
string s;
s << input;
EDIT:Code:unsigned long long input = 1234ULL; stringstream ss; string s; ss << input; ss >> s; // or s = ss.str();
Oops, unsigned long long, not unsigned long. Note that (signed/unsigned) long long is non-standard in C++ though available as an extension on some compilers.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
and __int64 on some others.
> in c there is a way of getting a unsigned long long into a char array by using sprintf,
Yes there is, but the conversion format still depends on your OS/Compiler (until everyone supports C99 properly).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^