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
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
Why flag is used in c?
Can we change the value of #define in c?
how could explain about job profile
What are the different types of objects used in c?
I came across some code that puts a (void) cast before each call to printf. Why?
Write a program to find the biggest number of three numbers in c?
What is the use of a static variable in c?
a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor
Explain what is the advantage of a random access file?
plz let me know how to become a telecom protocol tester. thank you.
What is a built-in function in C?
How do you use a pointer to a function?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
hi, which software companys will take,if d candidate's % is jst 55%?