Wednesday 27 March 2013

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


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

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

#include<stdio.h>
int main(){
   const int i=10;
    int *ptr=&i;
    *ptr=(int *)20;
    printf("%d",i);
    return 0;
}

Output: 20 


Blog Author: Vijay Kumar

No comments:

Post a Comment