I am trying to understand this whole pointer and dereference thing in C. I almost got it, but bumped into pretty simple code, which result I don’t understand:
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);
Now, as I understood before execution, ptr == chrptr == &val, but in reality ptr != chrptr == &val. Why is this?
val has its own memory location, so the address of val will be different