Tech Journal Back to Tech Journal

What does const mean in C variable and argument declarations?

If you have a variable (or function argument - it doesn't matter) declared as const char *a, that makes

a=NULL;     // legal
*a = 'a';   // not legal

However, if it's declared as char * const a, then

a=NULL;     // not legal
*a = 'a';   // legal

Quotes from Bob Elman (The C Guru!):

Last updated on 2005-06-21 14:00:00 -0800, by Shalom Craimer

Back to Tech Journal