Classical Algorithm _ Preprocessing

Source: Internet
Author: User

Pretreatment

1 Macro Definitions

2 file contains

3 conditional Compilation

1 Macro Definitions

Software engineering rules, macro definition in English capital

Define does not perform type checking and is only replaced, so some situations can go wrong.

As far as possible without define, when initialized with Const,const, will be automatically type conversion, there will be type check

1 #define_crt_secure_no_warnings2 3#include <stdio.h>4#include <stdlib.h>5 6 #defineM 10.07 8 Main ()9 {Ten     Const intN =10.9; One  Aprintf"%d\n", M);//define does not perform type checking and is only replaced, so some situations can go wrong.  -  -printf"%d\n"+ i);//as far as possible without define, when initialized with Const,const, will be automatically type conversion, there will be type check the  -System"Pause"); -}

3 conditional Compilation

1 #define_crt_secure_no_warnings2 3#include <stdio.h>4#include <stdlib.h>5 6 #defineCN "Hello World"7 #defineEn "Hello World"8 9 #defineB 1//define a macro that has a selection of compiled statements, such as a set of encodings that should be two versions in both English and ChineseTen  One Main () A { -  - #ifB = = 1 the { - printf (CN); - } - #else + { - printf (en); + } A #endif at  -System"Pause"); -}

Classical Algorithm _ Preprocessing

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.