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

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

3239


Why flag is used in c?

1125


Can we change the value of #define in c?

995


how could explain about job profile

1915


What are the different types of objects used in c?

1023


I came across some code that puts a (void) cast before each call to printf. Why?

1210


Write a program to find the biggest number of three numbers in c?

1041


What is the use of a static variable in c?

1055


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

1083


Explain what is the advantage of a random access file?

1115


plz let me know how to become a telecom protocol tester. thank you.

2188


What is a built-in function in C?

1587


How do you use a pointer to a function?

1077


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.

1681


hi, which software companys will take,if d candidate's % is jst 55%?

2090