#include <stdio.h>
#include <stdlib.h>
int main()
{
char word[256];
printf("%p \n", word);
// 0x7ffeefbff450
printf("%p \n", &word[0]);
// 0x7ffeefbff450
// Wrong
printf("%p \n", &(&word[0]));
// Meaningless to ask the address of an address
return 0;
}
For a given array
char word[256]
The name word
is equivalent to the address of the first element in the array
First element in array word is word[0]
, its address is &word[0]
word == &word[0] ----> &word == &(&word[0])----> Undefined
&
is applied only to variable name, not to variable address
int number;
scanf("%d",&number);
number
is not an array, so number
is the name of a variable not an address
To get the address of the variable number
, do &number
will &(&number)
make sense to you?