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 are unions in c?
What is getch() function?
simple program of graphics and their output display
Give the rules for variable declaration?
In which language linux is written?
What does the c in ctime mean?
Should I learn data structures in c or python?
What is file in c language?
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'); }
Explain how can I avoid the abort, retry, fail messages?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
How many loops are there in c?
What is the difference between the local variable and global variable in c?
What is the stack in c?
What are the benefits of c language?