Hi everybody,
I need to convert an unsigned long long number (64 bit) into string with C++ 2005.
The number for example is:
13057201162865595358.I want to write this value in a text file, but when i try to use ultoa to convert the number the result is 292279262.
Here is the code:
unsigned long long mt; char buffer[64];mt=13057201162865595358;
ultoa(mt,buffer,10);
The result in "buffer" is the number mentioned above.
Anyone can help me
Thank's in advance
Andrea

Converting 64-bit number into string
David Krmpotic
Your input number 13057201162865595358 is more than 8 bytes. ultoa can only convert 4 byte numbers. You can convert 64 bit numbers using _i64toa.
manick312938
Thank's for your help,
I made a little change, with your example and the number 13057201162865595358 the result is a negative number, but if I use "
_ui64toa" the result in "buff" is exactly the string "13057201162865595358".Bye...
Andrea
Troy Lundin
Have you tried
sspintf(buffer,"%I64d",mt)
jdrawmer
A small correction. _i64toa is deprecated, _i64toa_s is a more secure version.
Please see http://msdn2.microsoft.com/en-us/library/0we9x30h(VS.80).aspx
Regards
Sahir Shah