2013-03-18 368 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