how to typedef a constant variable

c, typedef

Solution

typedef char* ptr;
const ptr p;

The latter line is equivalent to

char * const p;

i.e. `p` is a `const` pointer to `char`. The `typedef` introduces a new name for a type, it is not a textual substitution.

Problem

``` typedef char* ptr; const ptr p; ``` Which is true: - `p` points to a constant character; or - `p` is a constant and points to a character. Please explain the reason

Original source