0
What is the output of the following code? Char*a="Coding"; char*b=(++a) +3; printf("%c", *b) ;
Explain the answer.
2 Answers
+ 3
About "What is the output" ...
You can test run the code in Playground.
As for the explanation ...
char *a = "Coding";
char *b = (++a) + 3;
// ++a adjusts pointer <a> to point to the next char, so <a> by now points to "oding"
// (++a) + 3 sets pointer <b> to point to the fourth char after initial address pointed by <a>, so <b> points to "ng"
printf("%c", *b);
// <b> is "ng", *b is 'n' (the value at that address)
0
n