Pointer function pointer array, function pointer Array

Source: Internet
Author: User

Pointer function pointer array, function pointer Array

Pointer variable analysis principle: Starting from the variable name, combined according to the operator priority, step by step analysis. (SlavePRemove the parentheses after the start.)

Pointer, pointing to what (X), what type of X is

Int * p; // start with P, and first combine with *, indicating that P is a pointer, and then combine with int, indicating that the type of content pointed to by the pointer is int, so P is a pointer to return integer data.

Int * p [3]; // starting from P, it is first combined with [], so P is an array, and then combined with *, indicating that the elements in the array are pointer types, then combined with Int, it indicates that the pointer points to an integer content type. Therefore, P is an array composed of pointers that return integer data;

Int (* p) [3]; // starts from P, first combines with *, indicating that P is a pointer, and then combines, it indicates that the pointer points to an array and then combines it with int, indicating that the elements in the array are integer, so P is a pointer to an array composed of integer data;

Int p (int); // starts from P, and is first combined with (), indicating that P isFunctionThen, go to () to analyze it, indicating that the function has an integer variable parameter, and then combine it with the int, indicating that the return value of the function is an integer data;

Int (* p) (int); // starting from P, it is first combined with the pointer, indicating that P is a pointer and then combined with (), indicating that the pointer points to a function, then it is combined with the int in (), indicating that the function has an int-type parameter, and is combined with the outermost int, indicating that the return value type of the function is int, so P isRefersDirectionWhich has an integer parameter and returns an integerFunction pointer.

A pointer is a special variable. The number stored in it is interpreted as an address in the memory. To understand a pointer, we need to understand four aspects of the pointer:The memory area occupied by the pointer, the value of the pointer, the memory area pointed to by the pointer, and the type of the pointer.,The type to which the Pointer Points.

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.