tijoriwalaritesh
Programmer
Below is a simple program.
int i = 0;
printf("%d %d %d %d", i++, i==1, i, ++i)
Its giving this output:
On Sun Solaris 8:
0 1 2 2
On Linux:
1 1 1 1
On Windows:
0 1 1 2
Can any one explain me how the compiler behaves in any particular case. I know the code is compiler dependent. Lets assume on linux.
also check your explanation with this one:
int i = 0;
printf("%d %d %d %d", (i++) + (++i), i==1, i, ++i)
int i = 0;
printf("%d %d %d %d", i++, i==1, i, ++i)
Its giving this output:
On Sun Solaris 8:
0 1 2 2
On Linux:
1 1 1 1
On Windows:
0 1 1 2
Can any one explain me how the compiler behaves in any particular case. I know the code is compiler dependent. Lets assume on linux.
also check your explanation with this one:
int i = 0;
printf("%d %d %d %d", (i++) + (++i), i==1, i, ++i)