Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls send me ans as soon as possible..

Thanks in advance for your answers
Posted
Updated 11-Mar-12 1:55am
v2

Under some circumstances, and depending on the variable, and the system you are running on, and the specific compiler, then yes, you can. But it is strongly recommended that you don't.

What part of constant is troubling you?

Constants should be treated as just that: values which do not change. Any change in constant values leads to code that is hard to maintain, hard to understand, and generally not worth keeping.

There are almost certainly better way to handle whatever your problem is: look for them instead.
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900