What is the difference between constant pointer and pointer
to a constant. Give examples.
Answer Posted / vignesh1988i
Constant pointer :
it is a pointer which points to the same memory location or
to same address and and whatever value the variable which is
pointed by the pointer holds.
for eg :
char a;
char const *p;
p=&a;
here var. a is a memory location having a address and that
variable contains some character data . but this pointer
p points to the same address ( a ) however the value in
var. a changes. finally, THE POINTER POINTED TO AN ADDRESS
IS A CONSTANT ,WHATEVER THE VALUE INSIDE THE VARIABLE MAY BE..
POINTER TO A CONSTANT :
this is a pointer which points to a constant variable
assigned to that pointer. and another pointer can also be
assigned to a same const. variable to point to.
for eg :
char Const a;
char *p,*q;
p=&a;
q=&a;
thank u
| Is This Answer Correct ? | 32 Yes | 0 No |
Post New Answer View All Answers
What is a far pointer in c?
What is the basic structure of c?
Can one function call another?
Define circular linked list.
What do you mean by command line argument?
how can I convert a string to a number?
number of times a digit is present in a number
Can stdout be forced to print somewhere other than the screen?
Why do we use int main instead of void main in c?
What is context in c?
Why c is called procedure oriented language?
Is it possible to execute code even after the program exits the main() function?
How can you determine the size of an allocated portion of memory?
What is the difference between abs() and fabs() functions?
How pointers are declared?