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
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What is data structure in c language?
Can a void pointer point to a function?
What is the easiest sorting method to use?
what is the difference between class and unio?
How can you find the day of the week given the date?
What is the benefit of using #define to declare a constant?
What does %2f mean in c?
What is structure pointer in c?
What is pointer in c?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
what do the 'c' and 'v' in argc and argv stand for?
Write a simple code fragment that will check if a number is positive or negative.
How can you increase the size of a statically allocated array?
What is difference between constant pointer and constant variable?