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


Please Help Members By Posting Answers For Below Questions

How can I trap or ignore keyboard interrupts like control-c?

607


FILE PROGRAMMING

1771


Write a program to print fibonacci series without using recursion?

599


When can you use a pointer with a function?

557


What does the error 'Null Pointer Assignment' mean and what causes this error?

732






how to create duplicate link list using C???

2061


What are the different types of data structures in c?

593


Why do we use return in c?

560


All technical questions

1501


How do we declare variables in c?

561


how should functions be apportioned among source files?

616


Explain data types & how many data types supported by c?

575


What is indirection?

642


What is the scope of local variable in c?

567


Are there constructors in c?

586