I have executed the following program
Code:
#include <stdio.h>
struct test
{
int a,b,c;
}test;
struct test testObj;
main()
{
testObj.a = 100;
testObj.b = 200;
testObj.c = 300;
printf("%d %d %d \n", testObj, testObj, testObj);
return 0;
}
The output was - 100 200 300.
I was expecting ouput as - 100 100 100.
Can anyone explain why the output is like this?
I tried looking into the assembly code for the same program and I found that before a call to printf the elements are pushed into the stack as following
testobj+8
testobj+4
testobj
When I replaced the printf statement with the following one
Code:
printf("%d %d %d \n", testObj, testObj, testObj.b);
still I got the same o/p (even the assembly was also the same).
Is it related to the compiler?
Pointers please.....
Gvs