Int * p [3] and int (* p) [3], int difference

Source: Internet
Author: User

Int * p [3] and int (* p) [3], int difference

The two are actually the differences between the numeric pointer and the pointer array. One by one:
Int * p [3]; // defines a three-dimensional array. Each element p [0], p [1], and p [2] are pointers to the int variable.
Int (* p) [3]; // defines a pointer pointing to a three-dimensional array.

The differences and relationships between the two can be described using a two-dimensional array:

Int * p [3]; // defines p [3] as a pointer array.
Int (* q) [3]; // defines q As an array pointer.
Int a [4] [3]; // defines a two-dimensional array

P [0] = & a [0] [0]; // you can assign a value to the element in p [3] for the address of any element in a [4] [3 ].
Q = a [1]; // a [1] is actually a three-dimensional array. Its elements include a [1] [0], a [1] [1], a [1] [2], so
// A [1] indicates the first address of the array. This address can be used to assign a value to q.

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.