Small issues with two-dimensional arrays

Source: Internet
Author: User

Int main (INT argc, char * argv [])
{
 
Int A [2] [3] = {0, 8, 2, 3, 4, 5 };
Int ** P;
P = (INT **);
Cout <* (p + 1) <Endl;
 
Return 0;
}
 
 
 
What is output?

 

We all know that,

If it is ** (a + 1), the output time is 3.

If it is * (* A + 1), the output time is 8

What about P?

I ran it on vs2005.
00000008 output
If * (p + 2), the output is 00000002

 

Here it should be like this: for a [2] [3], a itself is a pointer array, which contains two pointers pointing to two int [3] arrays respectively.
However, when P obtains the pointer value of A, it thinks that it points to the memory as a pointer array. At this time, it points to the memory, which actually stores
For p + 1, it moves one digit backward, pointing to 8, and thinks it is a pointer, so the output is 00000008

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.