//The following program obtains the memory address of one of the 5 animal names entered by the user.
#include <stdio.h>
int main() {
const char* x[5]={"Lion","Tiger","Jaguar","Cheetah","Puma"};
//It is clear that &x[0]is equivalent toX. And, x[0]is equivalent to *x.
int i; //Basically, &x[i]is equivalent to x+i and x[i]is equivalent to *(x+i).
int *p;
printf("Write the name of an animal: ");
for(i = 0; i < 5; ++i) {
printf("The address of the chosen animal is:[%d] = %p\n", i, x[i]);
}
return 0;
}
这就是我所拥有的,除了我需要程序询问一只动物的名字,这样它才能给出它的记忆地址,因为程序问我动物的名字,但无论我写什么,它都会立即生成5个名字的地址.