This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A simple question on expression


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]