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
Differentiate fundamental data types and derived data types in C.
Define macros.
What are qualifiers in c?
What does c mean before a date?
What is substring in c?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
How do you define structure?
Explain what is the benefit of using enum to declare a constant?
Explain how can you determine the size of an allocated portion of memory?
Explain how can a program be made to print the name of a source file where an error occurs?
How can I trap or ignore keyboard interrupts like control-c?
What is the data segment that is followed by c?
Is javascript based on c?
Explain is it better to bitshift a value than to multiply by 2?
What is the main difference between calloc () and malloc ()?