what is the function of this instruction - #if 0

int test(b,c){

int a = 10;

#if 0
a = b;
#else
a = c;
#endif
}

Dear all,

Please refer the example code above..Can you tell me what are the function did?..What is the meaning of
#if 0..?..My friend said, if we use #if 0, then actually we want to comment out all the instruction inside the #if 0 condition but not for the else part..?..

int test(b,c){

int a = 10;

#if 0

// a = b;
#else
a = c;
#endif
}

So that,the output will be always -> a = c..

Is that right?..
Can you give me more explaination about the usage of #if 0? Thank you.

Your information, help and attention is much appreciated. Thanks a lot.!..

Best Regards,
Siti..:)
Last edited on
closed account (jwC5fSEw)
#if 0 is a preprocessor directive. It basically says that, if 0 is true, then include the following code; else, include that code. Because 0 means false in C++, a = b will never be executed, and a = c always will be.
You might also want to take a look at this -> http://www.cplusplus.com/doc/tutorial/preprocessor/
Dear Shadow Addict and m4ster roshi,

Your information, help and attention is much appreciated. Thanks a lot...:)

Best Regards,
Siti..:)
Topic archived. No new replies allowed.