what will be the o/p of this c code? why? [duplicate]
开发者_C百科Possible Duplicate:
in c printf() returns what
what will be the o/p of this c code? why?
i=printf("hellow");
printf("%d",i);
Thanks..
Homework? Anyway, printf returns the number of characters printed. That should help.
Output is
hellow6
as printf returns number of characters it has printed...
Output will be:
hellow6
Reason:
The first printf
will print 6 characters ("hellow"
), which will be the return value, assigned to i
.
The second printf
will print i
, which will be 6.
Since there is no NewLine or other separator specified, the two will be run together as hellow6
.
Assuming that you ran the code and see the output:
hellow6
The explanation is, printf returns the number of characters it was able to write successfully.
精彩评论