![]() |
| | #1 |
| UT2004 Addict Join Date: Dec 2004
Posts: 645
| Question 26 Answer seems wrong on site quiz Code: What is the outcome of running the following code: int c=0; cout<<c++<<c; Undefined 01 00 Code: psycho@Shiva:~/Programming/Laboratory$ g++ -ansi -pedantic -Wall coutUndefined.cpp psycho@Shiva:~/Programming/Laboratory$ ./a.out 01 |
| Kleid-0 is offline | |
| | #2 |
| Registered User Join Date: Sep 2004
Posts: 197
| I believe what is ment by Undefined, is its not stated specificly in the standard what will come out, so it can vary from compiler to compiler, and/or platform to platform. Basicly, you will never know the exact outcome, so don't expect what you got to be the same as what some one else would.
__________________ If any part of my post is incorrect, please correct me. This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted. |
| Xipher is offline | |
| | #3 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,676
| > I tried out the program and I keep getting 01... You misunderstand the nature of "undefined". http://www.eskimo.com/~scs/C-faq/q11.33.html This specifically includes all your expected answers, and a whole bunch of other outcomes as well. And yes, that quiz question has the right answer. http://www.eskimo.com/~scs/C-faq/s3.html You'll always come unstuck if you try and do too much with the increment and decrement operators. |
| Salem is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ! C question: what is wrong with this ? | aaronc | C Programming | 1 | 04-28-2004 12:29 AM |
| 5am question: What did i do wrong. | DeepBlackMagic | C++ Programming | 2 | 10-10-2003 04:30 AM |
| what does this warningmean??? | kreyes | C Programming | 5 | 03-04-2002 07:53 AM |
| Why did I get this question wrong? | DISGUISED | C++ Programming | 6 | 01-31-2002 04:15 PM |
| Ok, long code...and really short and quick Question and most probably answer. | incognito | C++ Programming | 1 | 01-23-2002 03:34 AM |