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 are examples of structures?
Give me the code of in-order recursive and non-recursive.
Explain how can I avoid the abort, retry, fail messages?
How can I sort more data than will fit in memory?
How can I recover the file name given an open stream or file descriptor?
What does != Mean in c?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
Why we write conio h in c?
write a program in c language to print your bio-data on the screen by using functions.
Explain how do you list a file’s date and time?
What does %d do in c?
What is page thrashing?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
Explain spaghetti programming?
What is the use of getchar() function?