1. const char *a;
2. char* const a;
3. char const *a;
-Differentiate the above declarations.
Answers were Sorted based on User's Feedback
Answer / manoj ku. dalai
Explaining With the examples.........
1) const char *a="xyz" (string is constant, pointer is not)
*a='x' (error)
a="hi" (legal)
2) char* const a="xyz" (pointer is constant, String is not)
*a='x' (legal)
a="hi" (error)
3) char const *a="xz" (string is constant, pointer is not)
a*='x' (error)
a="hi" (legal)
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / susie
Answer :
1. 'const' applies to char * rather than 'a' ( pointer to a
constant char )
*a='F' : illegal
a="Hi" : legal
2. 'const' applies to 'a' rather than to the value of
a (constant pointer to char )
*a='F' : legal
a="Hi" : illegal
3. Same as 1.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / srinivas
The answers for first and third case is fine,but in 2nd
case we cannot assign *a='F',becoz *a points to starting
address of the array you cannot change the value at that
address where the reference to that pointer is lost.
| Is This Answer Correct ? | 0 Yes | 1 No |
main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }
main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.
16 Answers Aricent, Cisco, Directi, Qualcomm,
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }
How to return multiple values from a function?
void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }
void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }
main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above
How to palindrom string in c language?
what is variable length argument list?