On the p+1 of two-dimensional array in C language and the opinion of p+1

Source: Internet
Author: User

I first published in 51CTO blog, there may be some mistakes, I hope that the great God more guidance! All right, gossip, let's go to the subject:

In the C language, there are many data types (Int, Float, Char ...), then the array is a constructed type of data that the individual considers an array to be a set of data with the same data type. Currently, our common array is one-dimensional, two-dimensional arrays. This article takes two-dimensional array as the problem, first of all, we look at a piece of code!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/71/E9/wKioL1XaxUPBURHEAAJyT60hMuw905.jpg "title=" Qq20150824135755.png "alt=" Wkiol1xaxupburheaajyt60hmuw905.jpg "/>

Through the code, we know * (p+1), the value of p+1 is the same, but the meaning is different, first say p+1, whether it is a one-dimensional or two-dimensional array, the array name can be a table two meanings: 1, a pointer to its starting element (A[0]), 2, to represent the memory of itself (sizeof (a)) This article mainly with the first layer meaning, the two-dimensional array name A,a represents the address of the first element in a two-dimensional array a[0], that is, &a[0], instead of the address of the array itself, the address of the array itself is represented by (&a). Because, there is an int (*p) [3]=a; Note that this array pointer points to the first element in a two-dimensional array (a[0], which is pointed to, then p+1, which points to the a[1] array, (P is of type int (*) [3]), So, * (p+1) is p+ 1 point to the content of the space, then, what is this content? In a two-dimensional array, the result of the operation is a one-dimensional array, then can represent the whole array of only the array name, the one-dimensional array name represents the first address of its first element, and does not represent the address of a one-dimensional array, that is, &a[1][0], then * (p+1) =&a[1][0];

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/71/E9/wKioL1XaxWnQ_V4IAAGk8EoEm3k186.jpg "title=" Qq20150824142445.png "alt=" Wkiol1xaxwnq_v4iaagk8eoem3k186.jpg "/>

Through, the code can see that the inference is correct. So if we want to take the values in the two-dimensional array, we can do the "*" Operation again, that is, * (* (p+1)) that is * (&a[1][0]), as shown in the code!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/71/EC/wKiom1Xaw2zyJZ-OAAFQeTTCdQI906.jpg "title=" Qq20150824143017.png "alt=" Wkiom1xaw2zyjz-oaafqettcdqi906.jpg "/>

This is my personal humble opinion, if there is wrong, please the great God pointing twos.

This article from "Yoko" blog, reproduced please contact the author!

On the p+1 of two-dimensional array in C language and the opinion of p+1

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.