2 ms·
Arrays and pointers are not the same in C, nor have they ever been. The difference is more than that of mere syntax choices for equivalent concepts. In the poi
by droithomme 9y ago
Arrays and pointers are not the same in C, nor have they ever been. The difference is more than that of mere syntax choices for equivalent concepts.
In the pointer version of the code, the pointer is reassignable. Only the data it references can't be modified, the pointer can. To prevent the pointer from being modified, the declaration should have been:
const char * const ptr = "Lorem ipsum";
With the array version, there is no pointer to be modified and so no need or ability to have a second const.