Displays some address values and array contents. - C Pointer

C examples for Pointer:Array Pointer

Description

Displays some address values and array contents.

Demo Code

#include <stdio.h>

int main(void){

    int arr[4][2] = { {2,4}, {6,8}, {1,3}, {5, 7} };
    //w  w  w . ja  va  2 s  . co  m
    printf("   arr = %p,    arr + 1 = %p\n", arr,         arr + 1);
    printf("arr[0] = %p, arr[0] + 1 = %p\n", arr[0],      arr[0] + 1);
    printf("  *arr = %p,   *arr + 1 = %p\n", *arr,        *arr + 1);
    printf("arr[0][0] = %d\n", arr[0][0]); 
    printf("  *arr[0] = %d\n", *arr[0]);
    printf("    **arr = %d\n", **arr);
    
    printf("      arr[2][1] = %d\n", arr[2][1]);
    printf("*(*(arr+2) + 1) = %d\n", *(*(arr+2) + 1));
    
    return 0;
}

Result


Related Tutorials