what is the difference between char * const and const char
*?
Answers were Sorted based on User's Feedback
Answer / brindha
Char* const p -> Here pointer P is a const pointer, which
means that this pointer can point to only one memory
location. eg. char* const p = &arr;
p++ ; -> This is invalid
const char* p -> this indicates that the data pointed by
the pointer p is constant & the value in that address
cannot be modified. eg. const char* p = 'a';
*p = 'b'; -> This is invalid
| Is This Answer Correct ? | 30 Yes | 2 No |
Answer / 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 |
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} what would be the output?
write C code to reverse a string such that if i/p is "abc defg hij klmno pqrs tuv wxyz" and the o/p should be "cba gfed jih onmlk srqp vut zyxw"
Can you mix old-style and new-style function syntax?
Why is c so popular?
find the output of the following program main() { int x=5, *p; p=&x; printf("%d",++*p); }
What are the advantages and disadvantages of c language?
Explain what are multibyte characters?
Why C language is a procedural language?
hello everybody can we change a the adress of a variabl i mean can i put for exemple for a int *p: &p=6 ?????????
What is a newline escape sequence?
What are variables and it what way is it different from constants?