#ifdef and #ifndef and #endif | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

#ifdef and #ifndef and #endif

So Could you tell please What are Uses of this three in c++ why we use this Can you explain the syntax

24th Dec 2020, 9:34 AM
MUKUL Choudhary
MUKUL Choudhary - avatar
1 Antwort
+ 1
We use them for safety, to make sure that we will not define the same thing twice using preprocessor, or if we want to do something if something is already defined as "#ifndef" is just "if not defined", and "#ifdef" is for "if defined" For example: #ifndef PI #define PI 3.14 #endif //____________ #ifdef PI #undef PI //undefining PI #define PI 3 #endif We can also use them to do something same as with "if" statement. You can get better answer by doing C course, or using search bar in your browser for some examples
24th Dec 2020, 10:09 AM
Michal Doruch