const int* — pointer to const int. int const* — const pointer to int. const int const* — const pointer to const int.
1int x = 10;2int y = 20;34// const int* — pointer to const5const int* ptr1 = &x;6// *ptr1 = 15; // Error! Cannot modify value7ptr1 = &y; // OK — can change pointer89// int* const — const pointer10int* const ptr2 = &x;11*ptr2 = 15; // OK — can modify value12// ptr2 = &y; // Error! Cannot change pointer1314// const int* const — const pointer to const15const int* const ptr3 = &x;16// *ptr3 = 15; // Error!17// ptr3 = &y; // Error!
Reading from right to left:
int* — pointer to int.int* const — const pointer to int.const int* — pointer to const int.const int* const — const pointer to const int.Alternative syntax (C++ style):
int const* — same as const int*.int* const — const pointer.int const* const — const pointer to const.