在c/c++中,整型通常来讲是32位的,如long、int等。而对于64位的整型,须要用一些特殊的定义。如long long或uint64_t。c++
这些值在使用printf输出时,须要作一些修正才能够正确输出,以下示例:ide
- #include <inttypes.h>
- #include <stdio.h>
- int main()
- {
- uint64_t t = 111111111111111142;
- printf("1. %d\n",t);
- printf("2. %lu\n",t);
- printf("3. " "%" PRIu64 "\n", t);
- return 0;
- }
用gcc编译,运行结果以下:ui
可见,只有使用第三种方法,才能够顺利的显示出64位的数值来。spa
另外,在VC10中,并无<inttypes.h> 。blog
VC10中有一个<stdint.h>,其中定义了uint64_t,但没有定义PRIu64。get
在gcc中,<stdint.h>是包含在<inttypes.h>中的。string
因此,上述的第三种方法,没法在VC中实现。在VC中,你们仍是使用std::cout做为输出方式吧。it