c - I am not familiar with this type of printf() statement . Why my output look like this ? thanks -
#include <stdio.h> int main() { int i=43; printf("%d",printf("%d",printf("%d",printf("%d",i)))); return 0; }
what use of nested printf()
? used value 43 how other values showing in output?
output:
43211
the return value of printf number of printed characters.
let's analyze what's going on.
printf("%d",printf("%d",printf("%d",printf("%d",i))));
the innermost printf("%d",i)
prints obviously43
i
43.
the next outer printf("%d",printf("%d",i))
prints 2
because length of output of previous printf 2
(length of "43").
so output is:
432
the next outer printf print 1
because length of output of previous printf length of "1"
1.
so output is:
4321
the outer printf print 1
again because length of output of previous printf length of "1"
1.
so final output is:
43211
Comments
Post a Comment