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
What is the explanation for the dangling pointer in c?
What is a rvalue?
What is an lvalue?
How can I run c program?
how to write optimum code to divide a 50 digit number with a 25 digit number??
Which is better pointer or array?
What is actual argument?
What are the two types of functions in c?
Explain modulus operator.
swap 2 numbers without using third variable?
What are global variables and how do you declare them?
What is the explanation for prototype function in c?
What is call by reference in functions?
What are the types of pointers?
Why is c called "mother" language?