How to access or modify the const variable in c ?
Answer Posted / samrat
You can modify the const variable in C by using pointers.
#include <stdio.h>
int main()
{
const int val = 20;
printf("Value is: %d\n", val);
int *ptr =(int*)&val;
*ptr = 2000;
printf("Value is: %d\n", val);
return 0;
}
Output
Value is: 20
Value is: 2000
| Is This Answer Correct ? | 13 Yes | 28 No |
Post New Answer View All Answers
What is a wrapper function in c?
What is array of pointers to string?
How can you determine the maximum value that a numeric variable can hold?
what is a constant pointer in C
cavium networks written test pattern ..
Explain what are linked list?
C program to find all possible outcomes of a dice?
Find MAXIMUM of three distinct integers using a single C statement
What is your stream meaning?
how is the examination pattern?
Explain how can I prevent another program from modifying part of a file that I am modifying?
What are preprocessor directives in c?
What is ctrl c called?
what will be the output for the following main() { printf("hi" "hello"); }
What would be an example of a structure analogous to structure c?