Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I construct preprocessor if expressions which compare strings?
How can I construct preprocessor if expressions which compare strings?
✍: Guest
You can't do it directly; preprocessor #if arithmetic uses only integers. An alternative is to #define several macros with symbolic names and distinct integer values, and implement conditionals on those:
#define RED 1
#define BLUE 2
#define GREEN 3
#if COLOR == RED
/* red case */
#else
#if COLOR == BLUE
/* blue case */
#else
#if COLOR == GREEN
/* green case */
#else
/* default case */
#endif
#endif
#endif
(Standard C specifies a new #elif directive which makes if/else chains like these a bit cleaner.)
2016-02-05, 8920👍, 0💬
Popular Posts:
Wha is the output from System.out.println("Hell o"+null);?Hellonull
What are some uses of Intranets & Extranets? An "intranet" is the generic term for a collect...
What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void...
Does .NET support UNICODE and how do you know it supports? Yes .NET definitely supports UNICODE. Try...
What is difference between SITP and UTP in testing ? UTP (Unit Test Plan) are done at smallest unit ...