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 wrapper function in c?

1118


What is array of pointers to string?

1087


How can you determine the maximum value that a numeric variable can hold?

1235


what is a constant pointer in C

1176


cavium networks written test pattern ..

4083


Explain what are linked list?

1047


C program to find all possible outcomes of a dice?

2363


Find MAXIMUM of three distinct integers using a single C statement

1069


What is your stream meaning?

1239


how is the examination pattern?

2021


Explain how can I prevent another program from modifying part of a file that I am modifying?

1092


What are preprocessor directives in c?

1102


What is ctrl c called?

1050


what will be the output for the following main() { printf("hi" "hello"); }

11009


What would be an example of a structure analogous to structure c?

1000