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

What is the main difference between calloc () and malloc ()?

568


Explain what header files do I need in order to define the standard library functions I use?

645


What is the use of printf() and scanf() functions?

625


Explain union.

633


Can you assign a different address to an array tag?

694






Why is c so powerful?

677


I have a varargs function which accepts a float parameter?

573


How do you generate random numbers in C?

649


Why C language is a procedural language?

614


Explain how do you list a file’s date and time?

615


What is the difference between c &c++?

641


Why string is used in c?

574


What is the right type to use for boolean values in c?

580


What is the purpose of macro in C language?

657


which is an algorithm for sorting in a growing Lexicographic order

1394