ExamVeda
Login
Home
This question belongs to C Program Pointer
Pointer
?

Comment on the following?
const int *ptr;

Answer & Solution
Correct Answer: Option A
int * : pointer to int
int const * : pointer to const int
int * const : const pointer to int
int const * const : const pointer to const int

Now the first const can be on either side of the type so:

const int * == int const *
const int * const == int const * const

So the above declaration is pointer to const int. Which means,we cannot change the value pointed by ptr.
Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
Amit Verma
Amit Verma 4 years ago
I do not think that it will not allow changing the value of a variable whose address will be stored in a constant pointer.
Kumar Chandan
Kumar Chandan 10 years ago
int const * : Point a constant int so its can not be changed.
Saloni Jagtap
Saloni Jagtap 10 years ago
please provide explanation for this question