我试图理解 C 中的整个指针和取消引用的东西。我几乎明白了,但遇到了非常简单的代码,结果我不明白:
char *ptr = "Characters";
char val = *ptr;
char *chrptr = &val;
printf("Value under character pointer is: %p / %c\n", &val, val);
printf("Dereferenced character pointer: %p\n", chrptr);
printf("Array pointer: %p\n", ptr);
现在,正如我在执行之前所理解的那样ptr == chrptr == &val
,但实际上ptr != chrptr == &val
。为什么是这样?