1. Order of function parameters:
Int I = 2;
Max (I, I ++ );
A. if the order is from left to right, It is max (2, 2 );
B. If the order is from right to left, it is max (3, 2 );
Write a function that is irrelevant to the order of values.
2. function value transfer features:
A. Different memory units are occupied by real parameters;
B. Unidirectional transmission.
3. extern can extend the function scope, whether in the same file or in different files.
4. const usage:
A. Modify the function parameter, indicating that this parameter cannot be changed
B. modifying a common variable indicates that the variable cannot be changed.
C. Modify pointer variables)
Example:
(1) const int * p = & a; equivalent to int const * p = &;
Indicates that the value pointed to by pointer p cannot be modified.
(2) int * const p = &;
The pointer p cannot be modified.
Differentiation Method: Check whether "const" is before "*" or later.
5. static usage:
A. restrict the scope of Variables
B. Set the storage domain of the Variable
6. Use a consortium to determine whether the CPU is large or small:
Int is_endian ()
{
Union {
Int;
Char B;
} B;
B. a = 0x01;
Printf ("% d \ n", B. B );
}
7. array and pointer:
A. Analyze char *;
(1) char *: removes a, variable type (pointer ).
(2) char: Remove * a, the type pointed to by the pointer.
B .int * p1 [10] (pointer array)
Int (* p2) [10] (array pointer, pointing to an array, each array element is of the int type ).
C. char a [5];
(1) char (* p1) [5] = & a; (correct)
(2) char (* p2) [5] = a; (error)
(3) char * p = a; (correct)
Here, a represents the address of the first element of the array, that is, & a [0]. Distinguish the first element address from the array address.
D. If a pointer incompatibility warning occurs, the pointer type should follow the left operand.
8. Scope of variables:
A. C compiler is optimized: no memory is allocated before variables are used. For example, the global variable int a is defined in the two files at the same time. Because they are not allocated memory, no error occurs during use. If int a = 1; int a = 2; is defined at the same time, the error occurs. It is best to add static before the global variable.
B. Block variables: A statement block exists during running.
C. Static local variables have a global lifetime, but their scopes are still function scopes.
D. If no explicit value is assigned to any variable in the static or global storage area, the system automatically assigns the value to zero.