Most of the time in c pointers and arrays are considered the same. Some differences are:
&pointer = Returns the address of the pointer.
&array = Returns the address of the first element.
sizeof( array) = Returns the total memory consumed by all elements of the array.
sizeof(pointer) = Returns the only memory consumed by the pointer variable itself.
Array variables cannot be reassigned, but pointer variables can.
int a[]; //array Int *p; //pointer
Let us consider that there is an integer pointer variable
int *i;
Now let us consider the result of the following job -
a = &i; //illegal assignment. a variable can not be updated or modified. p = &i; //legal assignment.
The above is the detailed content of Comparison of pointers and arrays in C language. For more information, please follow other related articles on the PHP Chinese website!