Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are examples of structures?

1022


Give me the code of in-order recursive and non-recursive.

1319


Explain how can I avoid the abort, retry, fail messages?

989


How can I sort more data than will fit in memory?

1040


How can I recover the file name given an open stream or file descriptor?

1029


What does != Mean in c?

986


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

1048


Why we write conio h in c?

963


write a program in c language to print your bio-data on the screen by using functions.

6728


Explain how do you list a file’s date and time?

987


What does %d do in c?

907


What is page thrashing?

1026


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1116


Explain spaghetti programming?

1188


What is the use of getchar() function?

1071