开发者

What would the C code display? [duplicate]

开发者 https://www.devze.com 2023-01-25 03:41 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: Reason for the Output Hi,
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Reason for the Output

Hi,

Can you please explain me the output of this code开发者_如何转开发 snippet? The answer is "d"

void main()
{
short int a=5;
clrscr();
printf("%d"+1,a);
getch();
}

Thanks.


"%d" + 1 is a pointer to "d", so in fact you are executing printf( "d", a );.


"%d"+1 is "d", therefore the output will be "d".


Question a part...

Why didn't the writer simply used:

printf("d");

Is it the same?

0

精彩评论

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

关注公众号