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 pointer in C

1186


How do you declare a variable that will hold string values?

1183


Write a program to swap two numbers without using the third variable?

1078


Describe newline escape sequence with a sample program?

1128


What are nested functions in c?

1032


what is recursion in C

1075


Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

1287


what is the role you expect in software industry?

2154


In which layer of the network datastructure format change is done

1892


What’s the special use of UNIONS?

1152


Explain what is a 'locale'?

1085


How can I open a file so that other programs can update it at the same time?

1190


What is the ANSI C Standard?

1284


largest Of three Number using without if condition?

1607


Mention four important string handling functions in c languages .

1117