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
Explain how do I determine whether a character is numeric, alphabetic, and so on?
What is the use of getch ()?
What is break statement?
What are the scope of static variables?
Explain what is the difference between text files and binary files?
How to find a missed value, if you want to store 100 values in a 99 sized array?
What are the uses of a pointer?
Is it cc or c in a letter?
What is the best way to store flag values in a program?
Where are local variables stored in c?
Explain what is wrong with this program statement? Void = 10;
Is c compiled or interpreted?
Discuss the function of conditional operator, size of operator and comma operator with examples.
What is c mainly used for?
why programs in c are running with out #include