2
#include<stdio.h>
int main()
{
printf("%d",printf("%d %d",2,2) & printf("%d %d",2,2));
}
输出就这样产生了:2 2 2 2 3
为什么printf在我的程序中输出这个?
我想不通为什么输出是这个样子。有任何想法吗?
#include<stdio.h>
int main()
{
printf("%d",printf("%d %d",2,2) & printf("%d %d",2,2));
}
输出就这样产生了:2 2 2 2 3
为什么printf在我的程序中输出这个?
我想不通为什么输出是这个样子。有任何想法吗?
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"
我喜欢你的答案更好。 – GManNickG 2011-01-30 09:39:21