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

Differentiate fundamental data types and derived data types in C.

806


Define macros.

1008


What are qualifiers in c?

763


What does c mean before a date?

827


What is substring in c?

850


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

782


How do you define structure?

778


Explain what is the benefit of using enum to declare a constant?

808


Explain how can you determine the size of an allocated portion of memory?

813


Explain how can a program be made to print the name of a source file where an error occurs?

927


How can I trap or ignore keyboard interrupts like control-c?

806


What is the data segment that is followed by c?

817


Is javascript based on c?

780


Explain is it better to bitshift a value than to multiply by 2?

934


What is the main difference between calloc () and malloc ()?

813