Arrays and pointers are closely related and can sometimes be used interchangeably.
Array name is the array pointer.
To read an string of char array:
char multiple[10]; scanf_s("%s", multiple, sizeof(multiple));
Here we didn't use the & operator.
We're using the array name just like a pointer.
Array name without an index value refers to the address of the first element in the array.
You can't change the address referenced by an array name.
The following code shows that an array name by itself refers to an address:
#include <stdio.h> int main(void) { char multiple[] = "My string"; char *p = &multiple[0]; printf("The address of the first array element : %p\n", p); p = multiple;/*www . j a v a 2s . co m*/ printf("The address obtained from the array name: %p\n", multiple); return 0; }
The expression &multiple[0] produces the same value as the expression multiple.
multiple evaluates to the address of the first byte of the array, and &multiple[0] evaluates to the first byte of the first element of the array.