#include #include using namespace std; const char *ptr1 = "modifiable"; const char * const ptr2 = "non modifiable"; char ptr3[] = "a string"; int main() { ptr1 = "coucou"; cout << "ptr1 = " << ptr1 << endl; // 1. not possible !!!! // error: assignment of read-only variable ‘ptr2’ ptr2 = "toto"; // 2. error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] strcpy(ptr2, "toto"); strcpy(ptr3, "toto"); cout << "ptr3 = " << ptr3 << endl; // 3. will produce overflow and Segmentation fault strcpy(ptr3, "totototototototototototo"); cout << "ptr3 = " << ptr3 << endl; return 0; }