C language using the #if #endif annotate or different operating main function

C language does not support embedded comments in the comment at this time may be utilized #if #endf, for example:

#include<stdio.h>
#include<iostream>

#if(0)
int main() {
    char* b;
    b = (char*)"hello";
    printf("%c\n", b[2]);
    system("pause");
    return 0;
}
#endif // 

#if(1)
int main() {
    printf("hello world\n");
    system("pause");
    return 0;
}
#endif // 

Wherein if #if (0) inside the parameter is 0, then the code is wrapped #if #endif compiler will not be, it can be embedded inside a comment. At the same time, this role is to bring one, if we want to run multi-segment code in a cpp file, while others do not require a run, you will not need to be run or compiled code with #if (0) # endif wrapped up.

Guess you like

Origin www.cnblogs.com/xiximayou/p/12121675.html