Saturday, 4 June 2016

What is difference between const char *ptr and char const *ptr in C programming

They are equivalent in syntax and semantics.

const char *ptr is same as char const *ptr;

Both form of declaration represents that they are pointer to const char type. I.e., value pointed by the address cannot be changed.

Even in declaration of normal variables const qualifier can be represented before or after the datatype.

For eg:
int const a; is same as const int a;