what is the difference between
const char *p, char const *p, const char* const p

Answers were Sorted based on User's Feedback



what is the difference between const char *p, char const *p, const char* const p ..

Answer / 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

what is the difference between const char *p, char const *p, const char* const p ..

Answer / singamsa

const char*p - p is pointer to the constant character i.e
value in that address location is constact

char const *p - same as above

const char* const p - p is the constant pointer which
points to the constant string, both value and address are
constants

Is This Answer Correct ?    115 Yes 49 No

what is the difference between const char *p, char const *p, const char* const p ..

Answer / vignesh1988i

CONST char *p:
here the const. keyword is coming before the data
type... so the string here will be the constant but not he
pointer...
char CONST *p:
here also the string will be the constant but not the
pointer...
CONST char* CONST p:
here both , the string as well the pointer will be constant

Is This Answer Correct ?    64 Yes 32 No

what is the difference between const char *p, char const *p, const char* const p ..

Answer / magdaleen

In a const char *p the chrac pointed by 'p' is a const, so
u cant change the value of the charac ponted by 'p', but u
can make 'p' refer to some other location.

In a char const *p, the ptr 'p' is constant not the
character refered by it, so u can not make 'p' refer to
anyother location, but u can change the value of the charac
pointed by 'p'

Is This Answer Correct ?    10 Yes 4 No

what is the difference between const char *p, char const *p, const char* const p ..

Answer / bhargav

Const char *P ->
declares a pointer through which you may be able to access
a char but you can not change it through the said pointer.
But the pointer itself can be changed.

char const *p ->
in this the value is constant

const char* const p ->
both address and value are constants

Is This Answer Correct ?    13 Yes 22 No

Post New Answer

More C Interview Questions

what is the advantage of function pointer

16 Answers   CMC, CS, Freshdesk, L&T, LG Soft, Matrix, TCS,


Write a program to swap two numbers without using third variable in c?

0 Answers  


can u suggest me am in a confusion to choose whether to go to c programming or a software testing . am a graduate in B.sc(electronics).

1 Answers  


What are the scope of static variables?

0 Answers  


What is pass by reference in functions?

0 Answers  






write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

0 Answers   IBM,


Explain what are multidimensional arrays?

0 Answers  


What does printf does?

0 Answers  


What is the Purpose of 'extern' keyword in a function declaration?

0 Answers  


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

0 Answers   HCL,


progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,


what is the value of 'i'? i=strlen("Blue")+strlen("People")/strlen("Red")-strlen("green")

7 Answers   Cadence, JNTU, Zen Technologies,


Categories