C Language Learning
When you are a beginner in C language, you may encounter some problems that cannot be understood, or the expressions are different from those in Mathematics Learning (such as operators). This requires that you not be discouraged, if you don't understand what it is, you need to think more and learn with courage. After you finish the chapter knowledge, the previous questions will be solved;
Definition
C language is a computer programming language. It features both advanced languages and assembly languages. It can be used as a system design language, writing work system applications, or as an application design language, writing applications that do not rely on computer hardware. Therefore, it is widely used.
Advantages of C Language
1. concise, compact, flexible, and convenient 2. Rich operators 3. Rich data structures 4.
C is a structured language. 5. c syntax restrictions are not strict, and the degree of freedom in programming is large. 6. C language allows direct access to physical addresses and direct operation on hardware. 7.
High quality of code generated by C language programs and high efficiency of program execution 8. Wide application scope of C language and good portability
Disadvantages of C Language
1. the disadvantage of C language is mainly manifested in Data encapsulation, which makes C very flawed in data security, which is also a major difference between C and C ++.
2. the syntax of C language is not very strict, the type constraints on variables are not strict, affect program security, and do not check the array subscript out of bounds. From the application perspective, the C language is more difficult to grasp than other advanced languages.
C source program structure features
1. a c language source program can be composed of one or more source files.
2. Each source file can be composed of one or more functions.
3. No matter how many files a source program is composed of, there is one and only one main function, that is, the main function.
4. The source program may contain preprocessing commands (the include command is only one of them). Preprocessing commands should usually be placed at the beginning of the source file or source program.
5. Each description and statement must end with a semicolon. However, the pre-processing command, function header and curly braces "}" cannot be followed by a plus sign.
6. identifier. At least one space must be added between keywords to indicate the interval. If there is an obvious delimiter, there is no space to separate it.
Four Program structures in C Language(1) Ordered Structure
(2)
Branch Structure
(3) Loop Structure
(4) modular program structure
Basic data types (5)
Void: Declares that the function has no return value or no parameter, declares that there is no type pointer, and explicitly discards the operation result.
Char: String type data, which is a type of integer data.
Int: Integer data, usually the machine font specified by the compiler
Float: Single-precision floating point data, a type of floating point data
Double: Double-precision floating point data, which is a type of floating point data.
Type modifier keywords (4)
Short: Modify int and short integer data. The modified int can be omitted.
Long: Modifies int and long integer data. The modified int can be omitted.
Signed: Modify integer data, Signed Data Type
Unsigned: Modify integer data, unsigned Data Type
Complex Type keywords (5)
Struct: Struct Declaration
Union: Shared body Declaration
Enum: Enumeration Declaration
Typedef: Declared type alias
Sizeof: Get the size of a specific type or a specific type of Variable
Storage-level keywords (6)
Auto: Automatically assigned and released by the compiler. Usually allocated on the stack
Static: It is specified as a static variable and allocated in the static variable area. When modifying a function, it is specified as a function scope within the file.
Register: It is specified as a register variable. It is recommended that the compiler store the variable in the register or modify the function parameters. It is recommended that the compiler PASS Parameters through the register instead of the stack.
Extern: Specify the corresponding variable as an external variable, that is, the variable or function definition is indicated in another file, prompting the compiler to find its definition in other modules when encountering this variable and function.
Const: Used in conjunction with volatile, the specified variable cannot be changed by the current thread/process (but may be changed by the system or other threads/processes)
Volatile: In combination with const, "CV feature" indicates that the value of a specified variable may be changed by the system or other processes/threads, forcing the compiler to obtain the value of this variable from the memory each time.
Process control keywords
Jump structure (4)
Return: Used in the function body to return a specific value (or void value, that is, no return value)
Continue: Ends the current cycle and starts the next cycle.
Break: Jump out of the current loop or switch structure
Goto: Unconditional jump statement
Branch Structure (5)
If: Condition Statement
Else: The Condition Statement denies the branch (used with if)
Switch: Switch statement (multi-branch Statement)
Case: Branch mark in the switch statement
Default: "Others" in the switch statement. Optional.
Loop Structure (3)
For: For loop structure, the execution sequence of for (1; 2; 3) 4; is 1-> 2-> 4-> 3-> 2... loop, where 2 is the cycle condition
Do: Do loop structure, do 1 while (2); the execution order is 1-> 2-> 1... loop, 2 is the loop Condition
While: While loop structure, while (1) 2; the execution order is 1-> 2-> 1... loop, 1 is the loop Condition
In the preceding loop statement, if the expression of the loop condition is true, the loop continues. If the expression is false, the loop jumps out.