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 is the main difference between calloc () and malloc ()?
Explain what header files do I need in order to define the standard library functions I use?
What is the use of printf() and scanf() functions?
Explain union.
Can you assign a different address to an array tag?
Why is c so powerful?
I have a varargs function which accepts a float parameter?
How do you generate random numbers in C?
Why C language is a procedural language?
Explain how do you list a file’s date and time?
What is the difference between c &c++?
Why string is used in c?
What is the right type to use for boolean values in c?
What is the purpose of macro in C language?
which is an algorithm for sorting in a growing Lexicographic order