C language sorting 10

Source: Internet
Author: User

// # Compared with # include, import prevents repeated imports and ensures that only one content value is copied.
// # Include "A. H"
// # Include "A. H"
// Modify multiple include as follows:
# Ifndef lessonpointhigher_a_h
# Define lessonpointhigher_a_h

Int max (int x, int y)
{
Return x> Y? X: Y;
}

# Endif

// Macro. Only commands starting with "replace "// #
// Naming rules: 1. All uppercase 2. K + hump (consisting of multiple words, the first letter of each word is capitalized .)
// For example, Max or Kmax
// Macro is not a variable
// # Define is used to define the macro count macro name

// No macro Parameter
# Define count 10 // do not add points later
// In the pre-compilation phase, replace count with 10.

// Notes when using macros:
// 1. When a macro is defined, no plus points are allowed. The semicolon is also part of the content to be replaced.
// 2. The parameters must be enclosed in parentheses.
// 3. For macro parameters, spaces cannot be added between macro names and brackets.


// Macro with Parameters
# Define sum (A, B) (a) + (B ))
// If you first calculate the macro defined by the Operation in the macro, add brackets # define sum (A, B) (a) + (B ))
// Macros do not limit Data Types
// Macro is only a replacement function
// Sum (5, 10) * sum (5, 10) equals 65


# Define AAAA
Int main (INT argc, const char * argv [])
{
// Compile different codes based on conditions. During the compilation, the source files are compiled into binary commands and stored in the code area. Conditional compilation is often used to debug programs.
// The first form of Conditional compilation
// # Ifdef identifier code segment 1 # else code segment 2 # endif
// If the identifier is defined by # define, code segment 1 is compiled; otherwise, code segment 2. # endif indicates the end of compilation.

# Ifdef AAAA
Int A = 10;
# Else
Int A = 20;
# Endif
Printf ("A = % d \ n", );
// The second form of Conditional compilation
// # Ifndef identifier code segment 1 # else code segment 2 # endif
// If the identifier is not defined through # define, code segment 1 is compiled; otherwise, code segment 2. # endif indicates the end of compilation.
# Ifndef AAAA
Int B = 10;
# Else
Int B = 20;
# Endif
Printf ("B = % d \ n", B );
// The second form of Conditional compilation
// # If constant expression code segment 1 # else code segment 2 # endif
// If the constant expression result is not 0, the compiler compiles code segment 1; otherwise, the code segment 2 is compiled.
# If 1
Int c = 10;
# Else
Int c = 20;
# Endif

// The struct pointer accesses the struct member and points to the operator, for example, the struct pointer variable-> struct member;
// Printf ("% s \ n", pstu-> name );
// Strcpy (pstu-> name, "Xiaoguang ");
// Printf ("% s \ n", pstu-> name );
/// Pstu ++; // increase the size of the entire struct.
/// * Pstu and Xiaoguang have the same functions. They all obtain the struct content.

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.