Arrays are closely related to pointers in C programming but the important difference between them is that, a pointer variable can take different addresses as value whereas, in case of array it is fixed. This can be demonstrated by an example:
printf("Address of c[%d]=%x\n",i,&c[i]);
Address of c=28ff44
Address of c=28ff45
Address of c=28ff46
Address of c=28ff47
Notice, that there is equal difference (difference of 1 byte) between any two consecutive elements of array.
Note: You may get different address of an array.
Relation between Arrays and Pointers
Consider and array:
In arrays of C programming, name of the array always points to the first element of an array. Here, address of first element of an array is &arr. Also, arrrepresents the address of the pointer where it is pointing. Hence, arr.
Also, value inside the address &arr and address arr are equal. Value in address &arr is arrand value in address arr is *arr. Hence, arr is equivalent to *arr.
&a is equivalent to (a+1) AND, a is equivalent to *(a+1).
&a is equivalent to (a+2) AND, a is equivalent to *(a+2).
&a is equivalent to (a+1) AND, a is equivalent to *(a+3).
&a[i] is equivalent to (a+i) AND, a[i] is equivalent to *(a+i).
In C, you can declare an array and can use pointer to alter the data of an array.
//Program to find the sum of six numbers with arrays and pointers.
printf("Enter 6 numbers:\n");
scanf("%d",(class+i)); // (class+i) is equivalent to &class[i]
sum += *(class+i); // *(class+i) is equivalent to class[i]
Enter 6 numbers: