Multidimensional Arrays and Pointers - C Pointer

C examples for Pointer:Array Pointer

Introduction

If you have a pointer and assign the address of the array to it, you can use the pointer to access the array members by modifying the address it contains.

Demo Code

#include <stdio.h>

int main(void)
{
  char board[3][3] = {
                       {'1','2','3'},
                       {'4','5','6'},
                       {'7','8','9'}
                     };/*from w  w w.  j  ava  2 s . c o m*/

  char *pboard = *board;             // A pointer to char
  for(int i = 0 ; i < 9 ; ++i)
  printf(" board: %c\n", *(pboard + i));

  return 0;
}

Result


Related Tutorials