I am new to C language. I have a confusion regarding pointers in C.
Here is a short program:
void main() {
int *array_ptr,big_array[20];
array_ptr=big_array;
}
Here when we equated pointer to the name of array then C will assign the address of first element of array to the pointer as it know that array_ptr
is a pointer and will store an address. Whereas in this case,
void main() {
int i, *x;
x = i;
}
Here, it will throw an error. In this, we have to use &i
to assign it to pointer x
.
why we need to use &
in case of integers/floats etc and don't need to use it in case of array?