C language preprocessing # If, # Elif, # endif, # ifdef, etc.

Source: Internet
Author: User

1. # define and # UNDEF define or cancel defining condition compilation symbols

2. # If, # Elif, # else and # endif are used to skip based on conditions.Source codeSection

3. # ifdef, # ifndef determine whether the symbol is defined

4. # error, # warning is used to issue errors and warnings

5. # Line

 

Example:

# Include "stdio. H "<br/> # define AAA 3 <br/> int main () <br/>{< br/> # If (AAA = 1) <br/> printf ("AAA = 1/N"); <br/> # Elif (AAA = 2) <br/> printf ("AAA = 2/N"); <br/> # else <br/> printf ("AAA = 3/N "); <br/> # endif </P> <p> # undef aaa </P> <p> # ifndef AAA <br/> printf ("AAA hasn't been defined! /N "); <br/> # else <br/> printf (" AAA has been defined! /N "); <br/> # endif </P> <p> # line 50 <br/> # warning // make a warning <br/> // # error // make a error <br/> // system ("pause "); <br/> while (getchar ()! = 'Q'); <br/>}< br/>

Result:

 

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.