Arrays and Pointers - C Pointer

C examples for Pointer:Array Pointer

Introduction

The array name refers to the address of the first element in the array.

You can change the address contained in a pointer, but you can't change the address referenced by an array name.

The following example shows how arrays and pointers work together.

Demo Code

#include <stdio.h>

int main(void)
{
  char multiple[] = "My string";

  char *p = &multiple[0];
  printf("The address of the first array element  : %p\n", p);

  p = multiple;/*  ww w.j  av  a2  s . co m*/
  printf("The address obtained from the array name: %p\n", multiple);
  return 0;
}

Result


Related Tutorials