3

Why does this work? It seems to me assigning a[0] = "X" should fail because const should make the data in the array immutable. However it compiles and runs fine, with and without const.

const char* a[] = {"a", "b", "c"};
a[0] = "X";
printf("%s\n", a[0]);
Aviv Cohn
  • 15,543
  • 25
  • 68
  • 131

0 Answers0