Chapter 3 of Expert C programming describes how to analyze complex statements. I am not fully familiar with the methods for analyzing complex statements introduced by the author. However, I have my own set of methods to parse complicated statements. It is called a great rule to refer to Rome. As long as the results are the same, you must care about the process. Today, I found several complicated statements on the Internet and practiced them. (the examples of the statements are all from the Internet. Sorry, the source is unknown ). Write down this article and mark it for future aftertaste.
INT (* func) (int * P)
This will not be explained, and will be available in every reference C language. As a C/C ++ programmer, you are out ~~ _~~
INT (* func) (int * P, INT (* f) (int *))
Func is a pointer pointing to a function. The function receives two parameters. The first parameter is int *, and the second parameter is a function pointer (the function pointer receives the int * parameter, returns the int value). The function returns the int value. Use typedef to simplify the process:
INT (* func) (int * P, INT (* f) (int *);/* equivalent to */typedef int (* functor1) (int *); typedef int (* functor2) (int *, functor1); functor2 func;
INT (* func [5]) (int * P)
Func is an array containing five elements. Each element in the array is a function pointer. The function receives the int * parameter and returns the int value. Use typedef to simplify the process:
INT (* func [5]) (int * P);/* equivalent to */typedef (* functor) (int *); functor func [5];
INT (* func) [5]) (int * p ))
Func is a pointer pointing to an array containing five elements. Each element of the array is a function pointer. This function receives the int * parameter and returns the int value. The following code indicates what func is:
INT (* func) [5]) (int * P);/* func is the following stuff: */typedef int (* functor) (int *); functor arr [5]; func = & arr;
INT (* func) (int * p) [5]
Func is a pointer pointing to a function. The function receives the int * parameter and returns a pointer pointing to an int array containing five elements. Use typedef to simplify the process:
INT (* func) (int * p) [5];/* equivalent to */typedef int arr [5]; typedef arr * (* functor) (int *); functor func;
INT (* func) [5] [6]) [7] [8]
Func is a pointer to a two-dimensional array with 5 rows and 6 columns. The pointer is saved in the array. The Pointer Points to an int array with 7 rows and 8 columns. The following code may make you clearer:
int (*(*func)[5][6])[7][8];/* see it: */typedef int arr[7][8];arr *func1[5][6];func = &func1;
INT (* func) (int *) [5]) (int *)
Func is a function pointer. The function receives the int * parameter and returns a pointer pointing to an array containing five elements. The elements in the array are function pointers. The function receives the int * parameter, returns the int value. Use typedef to simplify the scheme:
INT (* func) (int *) [5]) (int *);/* equivalent to */typedef int (* functor1) (int *); typedef functor1 arr [5]; typedef arr * (* functor2) (int *); functor2 func;
INT (* func [7] [8] [9]) (int *) [5]
Func is an array of three. Each element in the array is a pointer. The Pointer Points to a function. The function points to the int * parameter. The return value refers to an int array containing five elements ), and typedef to simplify:
INT (* func [7] [8] [9]) (int *) [5];/* is equivalent to */typedef int arr [5]; typedef arr * (* functor) (int *); functor func [7] [8] [9];
After reading these examples, Are you dizzy? Hurry up and find a beautiful girl. Let's do some manual breathing for you ~ _~~~