Why are we allowed to change values of “const” qualified variables?Why pointers are allowed for this,but not assignment?
问题 Consider the following 2 programs prog1 and prog2 .Here if I try to change the value of the const qualified variable i using a pointer ptr ,I get the warning( not error) "initialization discards qualifiers from pointer target type|" ,but the program runs nevertheless and displays the new value.But if I try to change the value of i in the second program using an assignment statement,I get the error (not warning) assignment of read-only variable 'i'| . Here are confusions arising from this