what is the difference between char * const and const char
*?
Answer Posted / yathish nm yadav
CHAR * CONST
means we are making the variable of type
char* as constant i.e,
ex:
char * const p;
means pointer variable p is made constant i.e, its lvalue
is been blocked by compiler at compile time.
ex:
char c;
char *const p= &c;
here p contains the adress of c and we cannot make p now to
point to some other variable.
char t;
p=t; //compile time error.
CONST CHAR *
means the variable pointed to by the const char * is made
constant. i,e.
ex:
char c='a';
const char *p=&c;
here c is made constant n its lvalue is being blocked.
now we cannot change the value of c since it is made
constant.
i.e,
*p='b'; // error
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is c variable?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
What is the purpose of macro in C language?
how to write optimum code to divide a 50 digit number with a 25 digit number??
Is c language still used?
How are structure passing and returning implemented?
Why c is known as a mother language?
What is union in c?
What is the difference between volatile and const volatile?
What are the features of c languages?
Differentiate between the expression “++a” and “a++”?
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
Why is c so important?
Why is #define used?
In which layer of the network datastructure format change is done