C-language re-experience summary (i)

Source: Internet
Author: User

Preface
Beginning with iOS, I've been thinking about how to be a good programmer. The university missed too many so-called interest, examination-oriented education can not afford a glimmer of interest, unexpectedly in the senior middle school, found himself a forced, but fresh curious interest. Try a lot of things, once the profession but also feel strange, Feel afraid. There is always a result in everything, the process is their own understanding, even if the unsatisfactory will be rich and colorful.
-----to Cheng Meow's paper kite

Learn the summary of C language again

I. Keywords: special meaning of the Word 32 color special lowercase
1. Data type 20
1.1 Base data type (5) void Char int float double
1.2 Type modifier keywords (4) short long signed unsigned
1.3 Complex Type Keywords (5) struct Union enum typedef sizeof
1.4 Storage-Level keywords (6) auto Static register extern const volatile
2. Type of Process Control 12
2.1 Jump Structure (4) Return continue break got
2.2 Branch Structure (5) If else switch case default
2.3 Loop structure (3) for Do-while while

Two. Identifier: In addition to the system occupies 32 keywords, the rest of the expression function name, variable name is the identifier.
1. Usage Rules:
1.1 can only contain a digital letter underlined US $
1.2 Cannot start with numbers
1.3 cannot have the same name and cannot have the same name as the keyword
2. Specification:
2.1 The English paragraph that conforms to the program function, has the significance
2.2 Hump Name Method

Three. Note: Do not participate in the compilation, The green part, both Chinese and English can
1. Function:
1.1 Interpreting the Code
1.2 Sorting ideas
1.3 Error correction

Tips: The name of the identifier and the good use of comments are to help us understand the program, organize ideas, troubleshooting the important habit of error, every time Xcode training, should develop a good habit of commenting and naming.

Four. Data: Procedures of the blood, the power of the program, the most important thing is to pass the data. Call data follows from top to bottom, right-to-left principles.
1. Category
1.1 static data exists on the hard disk, persistent, slow to read eg: photos, music
1.2 Dynamic Data present in memory, short, read fast eg: search for information
2. Size: Data in the computer consists of 0 and 1 bits B M G T
3. Type
3.1 base data type (int float double char)
3.2 constructed type
3.3 pointer type
3.4 NULL type
4. Constant: Fixed data (emphasis) One of the helpers that passed the data leads to a wide variety of types
4.1 int
4.2 real: decimal
4.2.1 Single precision float
4.2.2 Double-precision doubles
4.3-character : A character enclosed in
4.4 string: One or more characters enclosed in
4.4.1 transfer character: special meaning character eg:\n carriage return \r=\013
5. Variable: Data that can be changed (important)
5. 1 Format: Data type (base data type) name
5.2 rule:
5.2.1 defines the data type, requests a piece of storage space, the size and type of the
5.2.2 variable must be initialized, otherwise it is garbage data 5.3 Variable scope: from definition to} or return 0
5.3.1 variable with the same name in different ranges
5.3.2 cannot appear in the same scope
5.3.3 large enclosing The memory of the local variable
5.4 variable
5.4.1 memory in bytes Apple is 64 bits
5.4.2 memory is large to small addressing
the address of the first byte stored by the 5.4.3 variable is the variable The address of the volume first defines the variable that the memory address must be greater than the later defined PS: Gets the address & variable name%p The address of the placeholder output is 16 binary.

Five. printf: Output data
1. Format: printf ("Format control string", output item list);
Six. scanf: input data
1. Format: scanf ("formatted string", $ input list item);

Seven. Operator: tells the data how to perform operations or complete specified actions
1. Breakdown by Function:
1.1 arithmetic operator +-x/%
1.2 Relational operators and logical operators > < >= <= = = = = && | | !
1.3 Bitwise operators
2. Operators are classified according to the number of operands involved in the operation
2.1 Single-Mesh operation
Monocular operation: Only one operand such as: i++! sizeof
2.2 Binocular operation
Binocular operation: There are two operands such as: a+b
2.3 Three mesh operation
Trinocular Budget: The only one in C language, also known as the question mark expression a>b? 1:0

Eight. Process Control
Process Control structure: sequence, selection, cycle
Order: Execute from top to bottom in writing order
Select: a given condition to determine which code is determined based on the result of the judgment
Loop: Executes a piece of code repeatedly under a given condition
1.switch

switch (conditional expression)//The return value of the conditional expression must be an integral type
{//Standard format
Case integer://case can be one or more
Statement
Break
Case integer:
Statement
Break

......

Default
Statement
Break
}
2.while
while (conditional expression) {//Condition not satisfied does not enter loop
Statement
....
}
3.do-while
Regardless of whether the condition satisfies the first cycle body,
Format: Do
{
}while (conditional expression);
4.for (initialization expression; conditional expression; post-loop increment expression)
Attention:
When the break statement is used in an do-while, for, and while Loop statement, the program terminates the loop
Instead of executing the statements that follow the loop, the break statement is always associated with the IF statement. That is, when the condition is met
Then jumps out of the loop.
1. The break statement does not work for if-else conditional statements.
2. In a multilayer loop, a break statement jumps only one layer outward.
3. Loops can be nested with each other

Common shortcut keys

command+s Save
command+r Run
command+b compiling
command+/ Single-line comment
command+/ add \ Next line also comment
command+shift+?? Select entire row
command+?? the leftmost side and the right end
command+option+ Direction key * Folding code
command+\ shortcut keys for adding breakpoints
command+opt+[] Move code up and down
command+] Right [ move left or
command+f can find all replacements
command+control+e Modify the name of the variable in the entire function

C-language re-experience summary (i)

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.