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

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file