"C-language exploration" two-dimensional arrays, meaning of two-dimensional array names

Source: Internet
Author: User

1. One-dimensional array of one-dimensional array names, representing two (1) representing the entire array (although Tan Don's book says no, but only in that context) (2) represents the first address

2. Two-dimensional array

It is troublesome to think of a two-dimensional array in terms of pointers, so I think of a way of understanding it myself, as shown in



the meaning of the two-dimensional array name feels uncomfortable, so find out what it stands for.
Here's my Code and the results
You can see that their four values are exactly the same, but with different meanings.1.b array name, which is a pointer to the entire array,2.*b is the initial address of the first dimension of the array, equivalent to b[0]3.&b purpose is to see the address of the array name, the final result is obvious, his address is also this4.&b[0][0] The address of the first element of the array
In summary, at the same address, there are three pointers (1) that refer to the array-name pointer for the entire array, respectively. (2) B[0 to the first-dimensional address]. (3) The address of the first element of the first dimension, that is, an array
so the two-dimensional array name can represent the meaning:
(1) The entire array, as long as the output sizeof (array name), output the length of the entire array(2) pointer to the first dimension(3) can also represent the address of the first element (since they are the same) int *p=a;

"C-language exploration" two-dimensional arrays, meaning of two-dimensional array names

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.