TOC | Prev | Next

const

const tells the compiler "I do not want to modify what this pointer points at."

const char event[] = "OSCON 2008";

const char *digit  = strchr( event, '8' );

if ( digit != NULL ) {
    *digit = '9'; /* fail */
}

const is a fantastic safety belt that is not used nearly enough.

TOC | Prev | Next