Differentiate between a constant pointer and pointer to a constant?
belongs to collection: C interview questions, your interviewer might ask
All Answers
total answers (1)
belongs to collection: C interview questions, your interviewer might ask
total answers (1)
Answer:
Constant pointer:
A constant pointer is a pointer whose value (pointed address) is not modifiable. If you will try to modify the pointer value, you will get the compiler error.
A constant pointer is declared as follows :
Let’s see the below example code when you will compile the below code to get the compiler error.
Pointer to a constant:
In this scenario the value of the pointed address is constant that means we can not change the value of the address that is pointed by the pointer.
A constant pointer is declared as follows :
Let’s take a small code to illustrate a pointer to a constant:
need an explanation for this answer? contact us directly to get an explanation for this answer