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 does printf does?
How are variables declared in c?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
Where in memory are my variables stored?
List some of the static data structures in C?
Explain how can I write functions that take a variable number of arguments?
Write a code of a general series where the next element is the sum of last k terms.
What is volatile c?
What is the meaning of && in c?
What are dangling pointers? How are dangling pointers different from memory leaks?
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
How do I convert a string to all upper or lower case?
What does c in a circle mean?
Is r written in c?