What is the difference between constant pointer and pointer
to a constant. Give examples.
Answer Posted / santosh
Pointer to constant: If pointer is pointing to constant
variable is caller pointer to constant. We can not change
the value of that constant.
const int constVariable = 6;
int *ptrConstVar = &constVariable;
Constant Pointer: We declare a pointer as constant. We can
change the content pointed by pointer. But we can not do any
airthmatic operation on the pointer like increment or decrement.
int localVariable =10;
const int *p = &localVariable;
we can not do p++ or p--;
| Is This Answer Correct ? | 23 Yes | 8 No |
Post New Answer View All Answers
What functions are in conio h?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
What are dangling pointers? How are dangling pointers different from memory leaks?
write a c program for swapping two strings using pointer
Is c procedural or object oriented?
What is ponter?
What do you understand by normalization of pointers?
How can I sort more data than will fit in memory?
Can you please explain the difference between syntax vs logical error?
Is c++ based on c?
what do you mean by enumeration constant?
What does the function toupper() do?
What is call by value in c?
What is the difference between array and linked list in c?
What is include directive in c?