Pointers
Dereference
Dereferencing a pointer reads or writes the object at the stored address.
Dereference
dereference.c
#include <stdio.h>
int main(void) {
int value = ;
int *ptr = &value;
*ptr = *ptr + 2;
printf("value=%d\n", value);
return 0;
}
#include <stdio.h>
int main(void) {
int value = ;
int *ptr = &value;
*ptr = *ptr + 2;
printf("value=%d\n", value);
return 0;
}
#include <stdio.h>
int main(void) {
int value = ;
int *ptr = &value;
*ptr = *ptr + 2;
printf("value=%d\n", value);
return 0;
}
dereference
`*ptr` means the object pointed to by `ptr`.
write through pointer
Assigning to `*ptr` updates the original variable.