The use of a two-dimensional pointer array and an array pointer-------a written-C + + paper

Source: Internet
Author: User

1. Don't say much, first on the code:

#include <iostream>using namespacestd;intMainvoid){        intv[2][5] = {{1,2,3,4,5},{6,7,8,9,Ten}}; int(*a) [5] = V;//pointer array, pointer to array a[5],a[5] inside is an int value the pointer equals v addresscout<< (*a+1) <<endl;//*a is the address of v[0][0]. 0x22fe04cout<< (*a+2) <<endl;//Output 0x22fe08cout<<* (*a+2) <<endl;//value of a[0][1] 3cout<<* (A +1) <<endl;//the address of the output V[1][0]. 0x22fe14cout<<** (A +1) <<endl;//a[1][1] = 6        intb[3]={ One, A, -}; cout<<"one-dimensional arrays:"<<Endl; cout<<b<<endl;//b[0] Address 0x22fe30cout<< (b +1) <<endl;//b[1] Address 0x22fe34cout<< (&b+1) <<endl;//LossAddress of the pointer pointing to B +sizeof (B[3]): 0x22fe3ccout<<* (b +1) <<endl;// Acout<<* (&b+1) <<endl;//The output is 0x22fe3c, the output is his address value (only remember first!!) )cin.Get(); return 0;}

2. The difference between an array of pointers and arrays:

Array of pointers: Int (*p) [3]; The pointer points to an array, and P is a pointer to the array p[3].

Array pointer: int p[3]; Array memory to data is pointer

----------is a bit like the pointer constant constant in the pointer, who first executes who reads first, then determines the specific meaning according to the direction of the reading.

The use of a two-dimensional pointer array and an array pointer-------a written-C + + paper

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.