2013-03-18 363 views

回答

0

我認爲你應該使用printf("%d\ll", bitmap2 & 1)而不是printf("%d\n", bitmap2 & 1),如果你想打印一個很長很長。

2

你目前看到的是未定義的行爲;你需要確保格式說明符和參數匹配。因此請使用以下選項之一:

printf("%lld\n", bitmap2 & 1); 
printf("%d\n", (int)(bitmap2 & 1)); 

請參閱http://en.cppreference.com/w/c/io/fprintf獲取printf的完整文檔。

但是,如果printf格式字符串與您提供的參數類型不匹配,大多數編譯器都會警告您。例如,如果我與-Wall標誌GCC編譯代碼時,我得到如下:

warning: format '%d' expects type 'int', but argument 2 has type 'long long int' 
+0

感謝 - 這個工作。 – user2184212 2013-03-19 22:58:11