Saturday, 28 February 2015

Write a c program to modify the constant variable in c++?

You can modify constant variable with the help of pointers. For example:

#include<iostream>
using namespace std;
void main(){
    int i=10;
    int *ptr=&i;
    *ptr=(int *)20;
    cout<<"i"<<endl;
    }

Output: 20 
If You Enjoyed This, Take 5 Seconds To Share It