Code: CPP
main()
{
int a=2;
printf("%d %d %d",a,a++,++a);
}
but
Code: CPP
main()
{
int a=2;
printf("%d",a);
printf("%d",a++);
printf("%d",++a);
}
may i know why?
altafahmed2k4@yahoo.co.in
|
Go4Expert Member
|
|
| 26Aug2006,18:11 | #1 |
|
Code: CPP
but Code: CPP
may i know why? altafahmed2k4@yahoo.co.in Last edited by shabbir; 26Aug2006 at 19:30.. Reason: Code formating. |
|
Go4Expert Founder
|
![]() |
| 26Aug2006,19:32 | #2 |
|
Welcome to G4EF.
Regarding the code snippets that you post in the threads please do use bb code to format the code snippets. Because it calculates right to left. See the out put of the following code Code: CPP
|
|
Contributor
|
|
| 1Sep2006,12:21 | #3 |
|
Quote:
Originally Posted by shabbir The OP's code has undefined behaviour. Last edited by Aztec; 1Sep2006 at 12:26.. |
|
Go4Expert Founder
|
![]() |
| 1Sep2006,14:08 | #4 |
|
Quote:
Originally Posted by Aztec |
|
Contributor
|
|
| 1Sep2006,15:43 | #5 |
|
Quote:
Originally Posted by shabbir |
|
Go4Expert Founder
|
![]() |
| 1Sep2006,15:51 | #6 |
|
Quote:
Originally Posted by Aztec TurboC2, TurboC3, BorlandC, Microsoft Visual studio and gcc compiler but there is no rule for behaving such. |
|
Contributor
|
|
| 1Sep2006,17:24 | #7 |
|
TurboC2, TurboC3--->Total Crap
BorlandC, Microsoft Visual studio and gcc compiler--->Yaa right What should I assume about version numbers. And why are you defending your wrong statement? You can not assume any particular order. It varies from compiler to compiler. In short, code has undefined behaviour.That's it. |
|
Go4Expert Founder
|
![]() |
| 1Sep2006,17:31 | #8 |
|
Quote:
Originally Posted by Aztec Quote:
Originally Posted by Aztec Quote:
Originally Posted by Aztec Quote:
Originally Posted by Aztec |