Jan 3, 2005 #1 A arm_learner Member level 2 Joined Jan 6, 2004 Messages 42 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,288 Activity points 322 Basic C Programming #define Z 1 #if Z A #else B #endif ******************** I want to know Z will select A or B? Thz!
Basic C Programming #define Z 1 #if Z A #else B #endif ******************** I want to know Z will select A or B? Thz!
Jan 3, 2005 #2 checkmate Advanced Member level 3 Joined Feb 25, 2004 Messages 832 Helped 178 Reputation 356 Reaction score 125 Trophy points 1,323 Location Toilet Seat Activity points 7,811 Re: Basic C Programming A will be chosen. 0 will be mapped to FALSE. Anything else will be mapped to TRUE.
Re: Basic C Programming A will be chosen. 0 will be mapped to FALSE. Anything else will be mapped to TRUE.
Jan 3, 2005 #3 R raj_rohit10 Advanced Member level 4 Joined Jul 14, 2004 Messages 100 Helped 2 Reputation 4 Reaction score 1 Trophy points 1,298 Activity points 891 Re: Basic C Programming it will certainly select A
Jan 4, 2005 #4 M muko Member level 1 Joined Mar 3, 2004 Messages 37 Helped 1 Reputation 2 Reaction score 0 Trophy points 1,286 Activity points 317 Basic C Programming certainnly A is chosen!
Jan 4, 2005 #5 I I AND MY SCIENCE Newbie level 4 Joined Jan 4, 2005 Messages 7 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 177 Re: Basic C Programming WE CERTAINLY GET A BECAUSE WE HAVE DEFINED Z=1 .
Jan 5, 2005 #6 S s2c97 Junior Member level 3 Joined Nov 20, 2004 Messages 26 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 292 Basic C Programming It will definitely be A. You defined Z=1 if Z=1 -> A else if Z= 0 -> B s2c97
Jan 5, 2005 #7 D DigitalScholar Newbie level 6 Joined Jan 3, 2005 Messages 13 Helped 1 Reputation 2 Reaction score 0 Trophy points 1,281 Activity points 109 Re: Basic C Programming As everybody else stated, It will select A. The reason being simple that the preprocessor will simply replace 'Z' with '1' wherever it encounters Z. So the preprocessor output will be like #if 1 A #else B #endif which obviously results in A. DigitalScholar
Re: Basic C Programming As everybody else stated, It will select A. The reason being simple that the preprocessor will simply replace 'Z' with '1' wherever it encounters Z. So the preprocessor output will be like #if 1 A #else B #endif which obviously results in A. DigitalScholar
Jan 8, 2005 #8 S swgchlry Member level 4 Joined Dec 8, 2003 Messages 69 Helped 1 Reputation 2 Reaction score 0 Trophy points 1,286 Activity points 718 Basic C Programming which obviously results in A
Jan 16, 2005 #9 N nj_jack Member level 5 Joined Nov 9, 2004 Messages 86 Helped 1 Reputation 2 Reaction score 0 Trophy points 1,286 Activity points 725 Basic C Programming This is a very simple question. A will be chosed.
Jan 16, 2005 #10 B boeysue Full Member level 3 Joined Dec 23, 2004 Messages 187 Helped 3 Reputation 6 Reaction score 0 Trophy points 1,296 Activity points 1,523 Re: Basic C Programming This will help some one to develope code during degugging. And than deleting the code of the 0 part.
Re: Basic C Programming This will help some one to develope code during degugging. And than deleting the code of the 0 part.
Jan 16, 2005 #11 T timber23 Newbie level 3 Joined Jan 7, 2005 Messages 4 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 44 Re: Basic C Programming arm_learner said: #define Z 1 #if Z A #else B #endif ******************** I want to know Z will select A or B? Thz! Click to expand... There's another way to do this which I personally prefer. #define DEBUG // use #undef DEBUG if not in debug mode #if defined (DEBUG) A #elseif B #endif or #undef DEBUG #if !defined (DEBUG) B #elseif A #endif
Re: Basic C Programming arm_learner said: #define Z 1 #if Z A #else B #endif ******************** I want to know Z will select A or B? Thz! Click to expand... There's another way to do this which I personally prefer. #define DEBUG // use #undef DEBUG if not in debug mode #if defined (DEBUG) A #elseif B #endif or #undef DEBUG #if !defined (DEBUG) B #elseif A #endif