"C Language and program design" two-dimensional arrays, array pointers, and pointer arrays

Source: Internet
Author: User

A two-dimensional array can be seen as a one-dimensional array of elements in a one-dimensional array, so the storage of two-dimensional arrays and the manipulation of pointers are easy to confuse:

Suppose there are one or two-dimensional arrays

A[3][4] = {{4,5,6}, {7,8,9}}

a--two-dimensional array name, which is essentially a pointer to the first element of the element's one-dimensional array with {4,5,6}, {7,8,9}, {a[0}, and its value is the address (the line address) of the elements.

a[0]--a one-dimensional array name, in essence, the first element pointer of a one-dimensional array of elements with a value of a[0][0] (the address of the column)

a[0][0]--elements of a two-dimensional array a[3][3] and a one-dimensional array (sub-array) a[0]

Can be seen

A+i=&a[i] Row address equal corresponding pointer to an array pointer such as (*P) [4]

a[i]=* (a+i) =&a[i][0] column address equal to the pointer is a normal pointer *p

But a is not a pointer array

"C Language and program design" two-dimensional arrays, array pointers, and pointer arrays

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.