C Pointer Essence

Source: Internet
Author: User

Let 's start with the simple type and analyze it slowly:

 

int p; This is an ordinary integer variable.

 

int *p; Start with P first, and then combine with * so that P is a

//Pointer, then combined with int, description pointer to

//content is of type int. So P is a return to the whole

pointer to//type data

 

int p[3]; Start with P, first with [] to show that P is a number

//Group, and then combine with int to show that the element in the array is an integer

//Type, so p is an array of integral types of data

 

int *p[3]; Start with P first, and [] first, because its priority

//ratio * High, so p is an array, and then combined with *, description

//The elements in the array are pointer types, and then combined with int,

//Description The type of content pointed to by the pointer is integral, so

//p is an array of pointers that return integer data

 

Int (*p) [3]; Start with P first, and then combine with * to show that P is a pointer

//And then combined with [] This step can be ignored, just for

//A change of priority), stating that the pointer points to something that is a

//array and then combined with int to show that the elements in the array are

//integral type. So P is a number that points to an integral type of data

//Group's pointers

 

int **p; Start with P first, combine with *, say P is a pointer, but

//later combined with *, indicating that the pointer points to the element is a pointer, however

//Then combined with int to show that the pointer points to an element that is an integer

//Type data. Because two pointers and more advanced pointers are rarely used

//In complex types, so the later more complex types we

//No multilevel pointers are considered, at most only one pointer is considered.

 

int P (int); Starting with P, we combine with () to show that P is a function and then enter

//() analysis, indicating that the function has a parameter of an integer variable

//Then combine with the outer int to indicate that the return value of the function is

//An integral type of data

Int (*p) (int); Starting at p, first with the pointer, the P is a pointer, and then the

///() The combination of the pointer to a function, then the//int with the (), stating that the function has an int type parameter, and then combining with the outermost//int, stating that the return type of the function is an integral type, so p is a reference// A pointer to a function that has an integer parameter and returns the type integer

 

int * (*p (int)) [3]; You can skip, not look at this type, too complex

//Starting from P, first with (), stating that P is a function and then entering

//Into (), in conjunction with int, indicates that the function has an integer variable

//parameters, then combined with the outside *, the function returned is

//A pointer, and then to the outermost layer, first and [] combined, indicating

//The returned pointer points to an array and then combines with *, saying

//The elements in the array are pointers, and then combined with int to indicate

//The PIN is pointing to an integer data. So p is a parameter for a

//Integer data and returns an array of integer pointer variables

//The function of the pointer variable.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.