If char*s are read only, why can I overwrite them?
The presented code snippet does not change the string literals themselves. It only changes the values stored in the pointer fruit. You can imagine these lines char* fruit = “banana”; fruit = “apple”; the following way char unnamed_static_array_banana[] = { ‘b’, ‘a’, ‘n’, ‘a’, ‘n’, ‘a’, ‘\0’ }; char *fruit = &unnamed_static_array_banana[0]; char unnamed_static_array_apple[] = … Read more