C/C++ Basic - protect data and pointer with const

char * const lpszct = "test"; //protecting pointer
char szBuff[10];
strcpy(szBuff, "123");
const char* lpctsz=szBuff; //protecting data pointed.

lpszct = "12"; //<-- compile error trying to change the pointer address

lpszct ++; //<-- compile error trying to change the pointer address

lpctsz[0] = '7'; //<-- compile error where trying to change the data

Comments

Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

MSSQL GROUP_CONCAT

Duplicating a local copy of project from TFS and making web software client factory to work