what is the difference between
const char *p, char const *p, const char* const p

Answer Posted / kumar krishna

CONST char *p;
here the const. keyword is coming before the "*p"
So it affects the value pointed by "p" i.e. "*p"
You can't change the character (value pointed by p).
Although you can change the address stored in "p".

char CONST *p;
same explanation as above

char * CONST p;
here the const. keyword is coming before the "p" and
after "*" So it affects the value of "p" (which holds
the address). You can't change the address stored in
"p". Although you can change the value pointed by p
i.e. "*p"

CONST char* CONST p:
here CONST is coming before the "*" as well as after
the "*". Therefore, as expeected neither the address
of nor the value pointed by "p" can be changed.

Is This Answer Correct ?    170 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the explanation for the dangling pointer in c?

664


What is a rvalue?

738


What is an lvalue?

625


How can I run c program?

675


how to write optimum code to divide a 50 digit number with a 25 digit number??

2739






Which is better pointer or array?

587


What is actual argument?

579


What are the two types of functions in c?

553


Explain modulus operator.

584


swap 2 numbers without using third variable?

652


What are global variables and how do you declare them?

608


What is the explanation for prototype function in c?

557


What is call by reference in functions?

548


What are the types of pointers?

590


Why is c called "mother" language?

849