Mega Code Archive

 
Categories / C Tutorial / Array
 

Accessing an array using pointers

The array name is the pointer constant. #include <stdio.h> main(){     int a[5];     int i;     for(i = 0;i<5;i++){         a[i]=i;     }     int *b;           b=a;          for(i = 0;i<5;i++){         printf("value in array %d and address is %16lu\n",*b,b);         b=b+2;     } } value in array 0 and address is 631652 value in array 2 and address is 631660 value in array 4 and address is 631668 value in array 631676 and address is 631676 value in array 42920 and address is 631684