When developing an application, you may often face a trouble that variables of the types __int64, size_t, or ptrdiff_t are printed incorrectly. First of all we should mention the difference between these data types. The __int64 type, for instance, always has the size 64 bits both on the 32-bit and 64-bit platforms. The types size_t and ptrdiff_t are 32-bit on the 32-bit platform and 64-bit on the 64-bit platform. It is this point that causes troubles and confusion when printing values of these types.
There are two ways to eliminate the problem:
For example, you can replace printf with cout, and sprintf with boost::format or std::stringstream.
a) For the __int64 type, regardless of the compiler (C++Builder, MSVC, or GCC):
b) For the types size_t and ptrdiff_t: