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...

wats the diference btwen constant pointer and pointer to a
constant.pls give examples.

Answer Posted / satyajit nayak

Hello All,
AS name suggested things are very simple.
1.Constant pointer
======================
it's nothing but a
(i)pointer which is pointing to a constant memory
location.
(ii)Once this pointer is assigned to point some location
we cann't make it to locate some other address location.
(iii)So constant pointer should be initialized at the
point of declaration only.

Example
=========
1. int main()
{
int * const my_ptr; //now my_ptr point to garbage
location
int var=10;
my_ptr=&var; //trying to modify my_ptr location.so
gives ERROR
}
so correct way of assignment is like
int main()
{
int var=10;
int * const my_ptr=&var;
printf("Addr=%x,val=%d",my_ptr,*my_ptr);
}

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between far and near in c?

1121


Why do we need a structure?

1082


What is the difference between array and linked list in c?

1209


Why is sizeof () an operator and not a function?

1091


Is struct oop?

1064


What is the difference between struct and union in C?

1387


How do you override a defined macro?

1317


Explain what is the difference between functions getch() and getche()?

1112


What is the difference between exit() and _exit() function?

1101


Explain how do you print an address?

1207


What are external variables in c?

1168


Write a function that will take in a phone number and output all possible alphabetical combinations

1101


Explain what is wrong with this statement? Myname = ?robin?;

1641


What is malloc calloc and realloc in c?

1428


What does s c mean in text?

1149