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 are unions in c?

573


What is getch() function?

645


simple program of graphics and their output display

1466


Give the rules for variable declaration?

669


In which language linux is written?

596






What does the c in ctime mean?

561


Should I learn data structures in c or python?

576


What is file in c language?

574


What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }

694


Explain how can I avoid the abort, retry, fail messages?

586


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2330


How many loops are there in c?

575


What is the difference between the local variable and global variable in c?

526


What is the stack in c?

714


What are the benefits of c language?

641