C language Composition
Variable statement function
Variable type: integer variable character variable floating-point variable (single-precision and double-precision floating-point type) void type
Char: one byte
Short:2 bytes
INT: Follow system 32-bit system 4 bytes
Float:4 bytes
Long:4 bytes
Double:8 bytes
A long double:10 bytes
type name |
Number of bytes |
Other Salutation |
range of Values |
Int |
* |
Signed, Signed int |
Depends on operating system |
unsigned int |
* |
Unsigned |
Depends on operating system |
__int8 |
1 |
Char Signed Char |
-128 to 127 |
__int16 |
2 |
Short Short int, Signed Short int |
-32,768 to 32,767 |
__int32 |
4 |
Signed, Signed int |
-2,147,483,648 to 2,147,483,647 |
__int64 |
8 |
None |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
Char |
1 |
Signed Char |
-128 to 127 |
unsigned char |
1 |
None |
0 to 255 |
Short |
2 |
Short int, Signed Short int |
-32,768 to 32,767 |
unsigned short |
2 |
unsigned short int |
0 to 65,535 |
Long |
4 |
Long int, Signed Long int |
-2,147,483,648 to 2,147,483,647 |
unsigned long |
4 |
unsigned long int |
0 to 4,294,967,295 |
Enum |
* |
None |
Same as int |
Float |
4 |
None |
3.4E +/-(7 digits) |
Double |
8 |
None |
1.7E +/-308 (digits) |
Long double |
10 |
None |
1.2E +/-4932 (digits) |
sizeof can find bytes
Limit.h inside Int_max can find maximum value int_min can be minimized
Declaring the meaning of a variable can be reused, and variable names can be read as much as possible when declaring variables
Statement: Sequential statement Loop Statement selection Statement (branch statement)
Sequential statements
Looping statements: for And while Do......while
SELECT statement: Switch
Function
Pointer: A memory space where the address is stored, and the pointer type determines how the content pointed to by the pointer is read. The address of the pointer holds the accuracy of the data (a memory leak occurs when an int pointer is held in a char type pointer, and the char type pointer is placed in the int type to produce some garbage values)
A struct can return multiple values, and a pointer can return only one value in C, and multiple values may be returned in C + +
Use variables instead of pointers whenever possible
Call to function
The call to the function is backtracking through the stack, and the arguments are passed through the stack.
C-language parameter delivery pass is an alias copy
Local variables
Pass-through parameter return address stored in the stack
Local variables consume memory in use, and when the function life cycle ends, it frees the current stack (local variables are released at this time)
1. When the function is called, it encounters a return, and if the function returns the address of a local variable, the address is invalid because the stack copies a copy when the called function is in use. After it is finished, the address of this local variable will be invalid, and the copy will not return to the address of the local variable in the original calling function.
2. When passing parameters, the function copies a copy of the current parameters to the stack for parameter passing, so any changes you make to the parameters within the function are modified aliases, and the copy itself does not change anything, because the value he holds does not change.
If you want to change the action to itself, pass in the address of the local variable.
The program occupies a piece of memory, as long as we can access the current memory in the program
Heap Area
Special area, managed by programmer, malloc allocates space.
Scope of use: More than 1MB there is another way to not want the program to release the space variables you allocated
Stack area
Use range: Only one use can not exceed 1MB, otherwise it will cause stack overflow
Global zone (static variable)
Global variables
Global constants
Code Area
C Language Summary