0
在Visual Studio 2012中,如果運行下面的代碼我得到的輸出作爲下面提到爲什麼輸出是這樣在Visual Studio 2012
typedef unsigned short u16;
typedef unsigned long long u64;
int main()
{
u16 i = 10;
u64 j = 1000;
printf("i= %d, j= %lu\n", i, j);
printf("j= %lu, i= %d\n", j, i);
getchar();
}
output:
i = 10, j = 1000
j = 1000, i = 0
//爲什麼?
使用'%llu'作爲'unsigned long long'。 – BLUEPIXY
我假設你問爲什麼'我'從'10'變爲'0'?看起來像一個錯誤。 Clang和GCC都沒有表現出這種行爲。 –
使用MSVC模式[這裏](http://rextester.com/l/cpp_online_compiler_visual),我注意到從'%lu'切換到'%llu'修復了輸出。不過,我不確定格式說明符爲什麼會影響我如何打印。 –