Quote:
Originally Posted by
kristinu
I want to know how it is that I can change desc when I declared desc as const.
You are mistaken. You have
not declared desc as const. desc is a memory address and it can change. However, the char that the memory address points to cannot be modified through desc.
Read hergp's response carefully.
Since desc is not constant, you can assign a new memory address to it, which is what's happening with
desc="string". What you cannot do (even if the memory is dynamically allocated) is indirect through desc to modify a character,
*desc='a'.
Regards,
Alister