#include <stdio.h>
// pointer can change, but the data cannot.
int main() {
const int value = 5; // immutable data
const int *ptr = &value; // pointer to const int (data cannot change)
printf("Value through ptr = %d\n", *ptr);
// *ptr = 10; // ERROR: cannot modify data through pointer
int other = 20;
ptr = &other; // pointer itself can change
printf("Now ptr points to %d\n", *ptr);
return 0;
}
/*
run:
Value through ptr = 5
Now ptr points to 20
*/