(C and pointers) #if 0/#if 1 ... #end If_c language

Source: Internet
Author: User

I. The role of "#if 0/#if 1 ... #endif"

1 code is defined in a number of debug version codes, this time the code is completely ignored by the compiler. If you want code to take effect, just change #if 0 to #if 1.

2 #if 0 There is also an important use for annotations, if you want to annotate the program is very long, this time #if 0 is the best, guaranteed not to make mistakes

#if 1 allows the variable to become a local variable.

3 This structure means that your previously written code, now used, and do not want to delete, use this method, more convenient than the annotation.

two. Examples

Copy Code code as follows:

#include <iostream>
int main (void)
{
int a = 0;
#if 0
A = 1;
#endif

printf ("%d\n", a);
return 0;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.