Pointers
Pointer Aliases
Two pointers can refer to the same object, so writing through one pointer changes what the other reads.
Pointer Aliases
pointer_aliases.c
#include <stdio.h>
int main(void) {
int value = ;
int *left = &value;
int *right = left;
*right = *right + 1;
printf("left=%d value=%d\n", *left, value);
return 0;
}
#include <stdio.h>
int main(void) {
int value = ;
int *left = &value;
int *right = left;
*right = *right + 1;
printf("left=%d value=%d\n", *left, value);
return 0;
}
#include <stdio.h>
int main(void) {
int value = ;
int *left = &value;
int *right = left;
*right = *right + 1;
printf("left=%d value=%d\n", *left, value);
return 0;
}
alias
Pointers alias when they store the same address.
shared object
A write through one alias updates the single shared object.