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
How can I trap or ignore keyboard interrupts like control-c?
FILE PROGRAMMING
Write a program to print fibonacci series without using recursion?
When can you use a pointer with a function?
What does the error 'Null Pointer Assignment' mean and what causes this error?
how to create duplicate link list using C???
What are the different types of data structures in c?
Why do we use return in c?
All technical questions
How do we declare variables in c?
how should functions be apportioned among source files?
Explain data types & how many data types supported by c?
What is indirection?
What is the scope of local variable in c?
Are there constructors in c?