![]() |
| | #1 |
| Registered User Join Date: Jul 2009
Posts: 4
| Code: int main()
{
int a=2,b;
b=++a+--a;
printf("%d %d",a,b);
}
|
| varadharajan is offline | |
| | #3 |
| Registered User Join Date: Jul 2009
Posts: 4
| What is undefined? |
| varadharajan is offline | |
| | #4 |
| Woof, woof! Join Date: Mar 2007 Location: Australia
Posts: 3,295
| |
| zacs7 is offline | |
| | #5 |
| Registered User Join Date: Jul 2009
Posts: 4
| I'm a new bee. Please help me to understand the working. |
| varadharajan is offline | |
| | #6 |
| Registered User Join Date: Jul 2009
Posts: 4
| Ok. Thank you for your kind reply. |
| varadharajan is offline | |
| | #7 |
| Woof, woof! Join Date: Mar 2007 Location: Australia
Posts: 3,295
| You couldn't have read that page in 2 minutes. There is no answer to spoon feed (not that I would anyway), it's undefined. |
| zacs7 is offline | |
| | #8 |
| Registered User Join Date: Feb 2010
Posts: 6
| so your preincrimenting a and then predecreminting it as well.... They make it undefined because its just bad programing behavior. And it is considered dangerous code. try this one out. Code: int i = 0;
int k = 0;
int j = 0;
if(++k > j || i++<k || j++ == k)
{
printf("%d, %d, %d",i , j, k);
}
|
| kille6525 is offline | |
| | #9 | ||
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 11,339
| Quote:
Quote:
![]() The code is perhaps a little obfuscated, but the result of the expression is well defined.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way | ||
| laserlight is online now | |
| | #10 | |
| Woof, woof! Join Date: Mar 2007 Location: Australia
Posts: 3,295
| Quote:
| |
| zacs7 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| K&R2 - Piece of code not working. | reqonekt | C Programming | 2 | 11-13-2009 11:07 AM |
| Having some real trouble with this code for a game I'm working on. | Swarvy | Game Programming | 3 | 05-09-2009 08:37 PM |
| please help me with this code... arrays arent working. | ominub | C Programming | 3 | 02-24-2009 08:49 PM |
| << !! Posting Code? Read this First !! >> | kermi3 | Linux Programming | 0 | 10-14-2002 01:30 PM |
| cygwin -> unix , my code not working properly ;( | CyC|OpS | C Programming | 4 | 05-18-2002 04:08 AM |