Relationship between two-dimensional arrays and array pointers

Source: Internet
Author: User

Since I wrote some questions about array pointers yesterday, let's write some topics about array pointers today.

Array pointer: A pointer to an array, that is, an array pointer, which is essentially a pointer

For example: Int (*a) [3]; is an array pointer, using the following

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main

{

int A[3][3] = {{1,2,3},{4,5,6},{7,8,9}};

int (*B) [3];

int i = 0,j = 0;

b = A;

for (i = 0; i < 3; i++)

{

for (j = 0;j < 3; j + +)

{

printf ("%d", b[i][j]);

}

}

}

Then we can find that we can print out all the numbers 1 to 9, which means that the function pointers and the two-dimensional arrays are used the same way; about pointer arrays and arrays of pointers how to say, the general usage is this, about their equivalence relationship I will show you:

Pointer parameters equivalent to array parameters

One-dimensional array char a[30] = = Pointer char *a;

Pointer array char *a[30] = = pointer of char **a;

The pointer char (*A) of the array of two-dimensional array char a[10][30] = = [30];

This is probably the case;

Relationship between two-dimensional arrays and array pointers

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.