Demonstrates the effect of adding an integer value to a pointer. - C Pointer

C examples for Pointer:Array Pointer

Description

Demonstrates the effect of adding an integer value to a pointer.

Demo Code

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

int main(void)
{
  char multiple[] = "a string";
  char *p = multiple;
  for(int i = 0 ; i < strnlen(multiple, sizeof(multiple)) ; ++i)
  printf("multiple[%d] = %c  *(p+%d) = %c  &multiple[%d] = %p  p+%d = %p\n",
                       i, multiple[i], i, *(p+i), i, &multiple[i], i, p+i);
  return 0;//from ww  w .  j a va2 s .c om
}

Result


Related Tutorials