The following program, what is the output result?
#include <stdio.h>
int main() {
int i = 43;
printf("%d\n",printf("%d",printf("%d",i)));
return 0;
}
Original series source: Several classic interview questions in C language under Linux
phpcn_u15822017-07-03 11:43:39
The answer is 43 2 1
Explanation: printf("%d", i) has a return value and returns the number of outputs
The above code can be converted to:
int i = 43;
a = printf("%d", i) # output: 43
b = printf("%d", a) # output: 2
printf("%d", b) # output: 1