A simple question on expression

Jie Zhang jzhang916@sina.com
Fri Aug 31 00:26:00 GMT 2001


Dear All,

I want to ask a simple question on expression.
Here are some statements:

int a;
a = 5;
a = 0?0:a++;
printf("a = %d\n", a);

a = 5;
a = (a<4)?0:a++;
printf("a = %d\n", a);


I compiled them using gcc-2.95.3 and found out the output is

a = 6
a = 5

Who can tell me why the two printfs print out different results?
I think both should be same.


Jie Zhang



More information about the Gcc mailing list