Pointers to Multidimensional Arrays, how you can use such a pointer like the original array. - C Pointer

C examples for Pointer:Array Pointer

Description

Pointers to Multidimensional Arrays, how you can use such a pointer like the original array.

Demo Code

#include <stdio.h>
int main(void)
{
    int arr[4][2] = { {2,4}, {6,8}, {1,3}, {5, 7} };
    int (*pointer)[2];
    pointer = arr;//from w ww  . j av  a 2  s  .  c o  m
    
    printf("   pointer = %p,    pointer + 1 = %p\n",pointer,         pointer + 1);
    printf("pointer[0] = %p, pointer[0] + 1 = %p\n",pointer[0],      pointer[0] + 1);
    printf("  *pointer = %p,   *pointer + 1 = %p\n",*pointer,        *pointer + 1);
    printf("pointer[0][0] = %d\n", pointer[0][0]);
    printf("  *pointer[0] = %d\n", *pointer[0]);
    printf("    **pointer = %d\n", **pointer);
    printf("      pointer[2][1] = %d\n", pointer[2][1]);
    printf("*(*(pointer+2) + 1) = %d\n", *(*(pointer+2) + 1));

    return 0;
}

Result


Related Tutorials