const char *
char * const
What is the differnce between the above two?
Answers were Sorted based on User's Feedback
Answer / karthik natarajan
const char * makes the data constant
char * constant makes the pointer constant
| Is This Answer Correct ? | 24 Yes | 1 No |
Answer / p s
const char *s; is a non-const pointer to const char
char * const s; is a const pointer to non-const char
Once u assign a value to the const poinet it cannot be
reassigned another value till u use casting techniques..
char a = 'A';
char b = 'B';
char *const c = &a;
c = &b; //flags an errror
const char *s = &a;
s = &b //works
| Is This Answer Correct ? | 19 Yes | 0 No |
Answer / beula
const char * is the pointer to a consant variable.
char * constant is a constant pointer to a char.
| Is This Answer Correct ? | 10 Yes | 1 No |
Answer / atreyee
char * const, the pointer is declared as constant.
const char *, the pointer is not constant.
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / sowmya.....
const char * is a constant pointer but,....
char * const is a pointer to constant
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / sahithi
const char* /*string is fixed pointer is not*/
char *const /*pointer is fixed string is not*/
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vidushi
Both are the method to declare a character pointer. but char
*const means pointer is sticked to accept a single address
but in case of const char * means u can assign it to
different variable address to it.
| Is This Answer Correct ? | 0 Yes | 2 No |
What are the basics of classifying different storage types, why?
2 Answers Astergate, Symphony,
What is a class template?
What are special characters c++?
What is conversion constructor?
Is set c++?
Explain this pointer?
program in c++ to input digits and print in words
given unsigned int ui1=3,ui2=7; what are the outputs of a)ui1 & ui2 b)ui1 && ui2 c)ui1 | ui2 d)ui1 || ui2 i also need the justification for the answers thank you
If there are 1 to 100 Numbers in array of 101 elements. Which is the easy way to find repeated number?
class Foo { const int x; protected: Foo(int f); ~Foo(); }; Foo f; Referring to the sample code above, why will the class declaration not compile? a) The variable x is const. b) The destructor is protected. c) The destructor is not public. d) The constructor is protected. e) There is no default constructor.
How can an improvement in the quality of software be done by try/catch/throw?
class basex { int x; public: void setx(int y) {x=y;} }; class derived : basex {}; What is the access level for the member function "setx" in the class "derived" above? a) private b) local c) global d) public e) protected