Converting _int64 to string
-
How can i convert _int64 to string? Normally whenever i need to convert numbers to string i use the following code: **************************************
int num = 123;
std::string strNum;
std::strstream strm;strm << num << std::ends;
strNum = strm.str();*************************************** This always works fine for me if the data type of a number is 'int' or 'float'. Today for the first time i need to convert an '_int64' number to string. I am using the code i described above but i get the following error: ServerMain.cpp(79) : error C2593: 'operator <<' is ambiguous Can anyone tell me the cause of problem and its solution
-
How can i convert _int64 to string? Normally whenever i need to convert numbers to string i use the following code: **************************************
int num = 123;
std::string strNum;
std::strstream strm;strm << num << std::ends;
strNum = strm.str();*************************************** This always works fine for me if the data type of a number is 'int' or 'float'. Today for the first time i need to convert an '_int64' number to string. I am using the code i described above but i get the following error: ServerMain.cpp(79) : error C2593: 'operator <<' is ambiguous Can anyone tell me the cause of problem and its solution
_int64 is a compiler specific data type. Therefor it is not supported by the STL which is by design compiler independant (at least it's supposed to). You can use the printf() family of functions, they support _int64 via the prefix I64 (but only on MSVC). So this should work: sprintf(my_char_buffer, "%I64i", my_int64_num); - askadar
-
_int64 is a compiler specific data type. Therefor it is not supported by the STL which is by design compiler independant (at least it's supposed to). You can use the printf() family of functions, they support _int64 via the prefix I64 (but only on MSVC). So this should work: sprintf(my_char_buffer, "%I64i", my_int64_num); - askadar
askadar wrote: _int64 is a compiler specific data type. Therefor it is not supported by the STL which is by design compiler independant (at least it's supposed to). However true, it's also irellevant. The STL (which technically has no merit any more, since Mars 1998) didn't even touch the matter. If we on the other hand talk about the C++ library: vendors are free to extend the library with e.g. compiler specific data types, and both Dinkum (MSVC7 and __int64, though with the name _LONGLONG) and the GNU C++ lib do provide these insertion operators for 64-bit integers (VC6 is another matter, but it's very easy to augment the lib to handle 64-bit integers). In fact I expect (especially for proprietary) compiler/lib combos to provide operators for all of the compilers POD types. I almost wrote "native types", but stopped myself knowing that any IA32 64-bit integer support must be emulated.