Const and pointers in C

The syntax of constant pointers in C can be confusing. Try reading from right to left, away from the variable name. E.g.

Pointer to a constant of type char:

const char *ptr_name;

Constant pointer to a variable of type char:

char *const ptr_name;

Constant pointer, to a constant of type char:

const char *const ptr_name;

Leave a comment