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 is a constant?

1113


Explain how do you determine whether to use a stream function or a low-level function?

1136


What is the difference between #include

and #include “header file”?

1092


What is class and object in c?

1177


Explain what is a pragma?

1091


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1426


What is the difference between Printf(..) and sprint(...) ?

1639


How can I make it pause before closing the program output window?

1081


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

1310


How to throw some light on the b tree?

1153


Is register a keyword in c?

1088


Which is the memory area not included in C program? give the reason

1998


What is modeling?

1097


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3310


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

1130