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 |
Why c++ is not a pure oop language?
How is modularity introduced in C++?
What is a list c++?
Write a program using display() function which takes two arguments.
What is function prototyping? What are its advantages?
Why do we learn c++?
What is different in C++, compare with unix?
There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?
What is an ABC: an "Abstract Base Class"?
What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard
What does the linker do?
How to write a program such that it will delete itself after exectution?