what is the difference between
const char *p, char const *p, const char* const p
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
How to add two numbers with using function?
write a proram to reverse the string using switch case?
what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
What is the value of c?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
What is the full form of getch?
cavium networks written test pattern ..
what is level of tree if leaf node is at level 4.please explain.
What does sizeof function do?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same