For C (as opposed to C++), this is explained here:
http://publications.gbdirect.co.uk/c_book/chapter8/const_and_volatile.html[
^].
In particular, please see Example 3.8 in the article referenced above. Usually, casting to a non-constant pointer is a bad thing, a sign of wrong code design, should be used with great care where it is really unavoidable.
Just in case: in C++, there is a template cast called
const_cast<>
. Please see:
http://www.cplusplus.com/doc/tutorial/typecasting/[
^].
—SA