C Language Learning Note (6): How to differentiate pointer arrays and array pointers from the surface of a variable declaration

Source: Internet
Author: User
Tags modifiers

Example:
int *p[5] is an array of pointers
int (*p) [5] is an array pointer
Distinguish between the two as long as the variable name p around the modifier can be.

Here are two points to be clear:
1, whether int *p[5] or int (*p) [5] should not be regarded as a whole, but should be regarded as some modifiers to modify the variable p, so that p is accurately defined;
2, [] The priority is higher than *, the same priority modifier, take a left-to-right compilation.

*P[5] because [] priority is high so [] first modifies the variable name p, so p is an array name, and then look at other modifiers, you can find an int * type of an array, that is, p is an array of pointers.

(*p) [5] because () and [] the priority of the same, so from left to right compile, then * first modify p, so p is a pointer variable, and then look at the surrounding other modifiers, you can find that p is an int array pointer.

C Language Learning Note (6): How to differentiate pointer arrays and array pointers from the surface of a variable declaration

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.