Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - When programming in C language, the pointer form of two-dimensional array should be written as int(*p)4. Why not write it as int*p4?
When programming in C language, the pointer form of two-dimensional array should be written as int(*p)4. Why not write it as int*p4?
First, the simplest way to shape a two-dimensional array is: int p [2] [4]; As a workaround, p is a pointer to an array containing four plastic elements.

So let's look at the difference between the two kinds of deformation.

The first thing to say is the priority of operators. The [] operator takes precedence over the * operator. So if you want to convert int p[2][4] into pointers, you need to use () to increase the priority of *: int (*p)[4]. This means that p is a pointer, and the element it points to is an array containing four plastic elements. Therefore, it is a two-dimensional array of n*4.

Int *p[4] means that p is an array, and an integer pointer is stored in the array. 4* 1 one-dimensional array.