From

xiaoxiao2021-03-06  104

Word Source VC World - C language classroom

Self-archiving, also dedicated to the same Delphi programmer as me

1. The pointer is an important part of the C language, using the pointer programming: (1) Improve the compilation efficiency and execution speed of the program. (2) It is easy to use the main adjustment function and the modulus or data structure between the main adjustment function and the modulated function to facilitate bidirectional data communication. (3) Dynamic storage allocation can be realized. (4) Easy to represent various data structures, write high quality procedures.

2. Calculation of the pointer (1) Take the address operator &: Address (2) Take the content operator *: Indicate the variable (3) assignment of the pointer (3) assignment the variable address to the pointer variable, the same type pointer variable Mutual assignment • Assigning the array, the first address of the string, imparts the function entry address to the pointer variable (4) add-oriented operation to the array, the pointer variable of the string can be subjected to addition, such as P N, PN, P , P - et al. Two pointer variables pointing to the same array can be subtracted. It is meaningless to point to other types of pointer variables. (5) The relationship operation points between the two pointer variables of the same array, which is less than, which is less than, equal to the comparative operation. The pointer can be compared to 0, and P = 0 means P is an empty pointer.

3. See the table below with various instructions and meaning related to the pointer. INT * p; P is a pointer variable INT * p [n] of the integer amount; P is the array of pointers, consisting of n points to the integer amount of pointer elements. INT (* p) [n]; p is a pointer variable to the integer two-dimensional array, the number of secondary arrays is nint * p () P is a function of returning the pointer value, the pointer pointing to the integer Int (* p) () P is a pointer to the function, which returns an integer amount INT ** P P to a pointer variable to another pointer, which points to an integer.

4. The description of the pointer is many of the pointers, arrays, and function descriptions. However, it is not a combination of any combination, such as an array cannot be composed of a function, ie array elements cannot be a function; the function cannot return a array or return another function. For example INT A [5] (); it is wrong.

5. With regard to parentheses, the square brackets and parentheses of the identifier are preferred over the "*" number left on the left side of the identifier, while square brackets and parentheses are combined from left to right from left to right in the same priority. However, the conventional binding order can be changed by cracker.

6. The rule of reading a combination indicator is "outward from." Starting with the identifier, first look at the brackets or garden brackets on the right, if there is any explanation, then look at the left side. If you have closed parentheses at any time, you must use the same rule to process the contents in parentheses before you continue. For example: int * (* (* a) ()) [10] ↑ ↑↑↑↑ 7 7 6 4 2 1 3 5 Same above gives the inside outward reading order, here to explain it: (1) Identification The characters are illustrated; (2) a pointer variable, it pointing; (3) a function, it returns; (4) a pointer, the pointer pointing; (5) A group with 10 elements, the type; (6) Pointer type, it points to; (7) INT data. Therefore, A is a function pointer variable that returns a pointer value to a pointer array, and the element of the pointer points points to an integer.

转载请注明原文地址:https://www.9cbs.com/read-125137.html

New Post(0)