I have a need to print 64 bit integer in Windows and UNIX environments.
Code Snipet:
unsigned __int64 mNumRowsRead=1234567890123456;
sprintf(buf, "%d row(s) read", mNumRowsRead);
sprintf(buf, "%s row(s) read", mNumRowsRead);
sprintf_s(buf, "%d row(s) read", mNumRowsRead);
itoa(mNumRowsRead,buff2,10);
cout << buff2 << endl;
sprintf_s(buf, "%s row(s) read", buff2);
First sprintf converted the 64 bit integer to 32 bits. The out interger is 1015724736 instead of 1234567890123456.
Second sprintf throws exception.
Third sprintf_s behavior like first one.
Last sprintf_s throws exception without itoa(). With itoa() the number was truncated. itoa() must not be able to handle 64 bit integer as expected. So, do we have 64 bit version of itoa()?? Or how do I print a 64 bit integer as part of a string. Thanks for the help.