I was reading a forum there i found following program.
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
the above program is working fine.
this meas i=6 and j=5.
any idea why i=6 and j=5 ( i was thinking i should be i=5 and j=6)and
what the "+" is doing in scanf?
Thanks for sharing comments.
Re: strange scanf
Shivanand Kadwadkar <email@example.com> writes:
> I was reading a forum there i found following program.
> int i, j;
> scanf("%d %d"+scanf("%d %d", &i, &j));
> printf("%d %d", i, j);
> the above program is working fine.
The program's meaning is undefined for at least two reasons. That means
that it is bound to work fine: since the program has no defined meaning,
anything it might do is as good as anything else.
> 6 5
I get something else (a segmentation fault) but that's also "working
A web search suggests this is an interview question, though where
answers are offered, none are correct.
|All times are GMT. The time now is 04:21 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.