How can we modify a constant variable?
suppose
const int x=12;
How can we change its value????
Please tell me.
How can we modify a constant variable?
suppose
const int x=12;
How can we change its value????
Please tell me.
All is well that ends well
Specify a pointer to the variable that you want to change. That should do the trick.
-----------------------------------------------
everready
To code, or not to code, that is the question.
Well the answer is 'TO CODE' of cause
You can only assign an address of a constant to a pointer to a constant so that wouldn't work. You can cast though -Specify a pointer to the variable that you want to change
const int a = 10;
const int* ptr = &a;
*(int *)ptr=20;
zen
Why make it const if you are going to want to change it? You are better off just being careful not too fool with it too much.
1978 Silver Anniversary Corvette