开发者

what will be the o/p of this c code? why? [duplicate]

开发者 https://www.devze.com 2023-02-15 09:32 出处:网络
This question already has answers here: Closed 11 years ago. 开发者_C百科 Possible Duplicate: in c printf() returns what
This question already has answers here: Closed 11 years ago.
开发者_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.

0

精彩评论

暂无评论...
验证码 换一张
取 消