vicky wrote, On 24/02/07 14:53:
why is the output of the following command is 4 4 5.
main()
{
int a=2;
printf("%d",printf("\n%d %d",a,a,a);
getch();
}
i did not understand what these two printf in a command signifies.
please help me
It isn't on my system. On my system the output is a compilation error.
Perhaps if you posted your actual code (copy and past, do not retype)
then a better suggestion could be given. Although I suspect even then
the answer will be "because it is since you invoked undefined behaviour".
A few general comment though, main returns an int and it is better to be
explicit about that (it is required in the latest C standard) and it is
also better to be explicit about not taking any parameters. Having
realised main returns an int you should then return one! Calling printf
requires a prototype, so you should include <stdio.h>. Standard C does
not have a getch function, it has a getchar function (prototype in
stdio.h) which probably does what you want, although learning to drive
your IDE would be better so you do not have to make the program pause.
So a slightly improved form would be:
#include <stdio.h>
int main(void)
{
int a=2;
/* Some printf calls, but I'm not sure what you intended */
getchar(); /* better to remove this, but I'll leave it in for you */
return 0;
}
--
Flash Gordon