#include<stdio.h>
int main()
{
printf("%d",printf("%d %d",2,2) & printf("%d %d",2,2));
}
输出如下:2 2 2 2 3
我无法弄清楚为什么输出是这样的。有什么想法吗?
答案 0 :(得分:15)
printf
返回打印的字符数,所以这里是解释:
printf("%d",printf("%d %d",2,2) & printf("%d %d",2,2));
\_________/ \_________________/ | \_________________/
| | | |
| prints "2 2" | prints "2 2"
| and returns 3 | and returns 3
| |
| computes 3 & 3
| (which equals 3)
|
prints "3"