What will be the output of the following C code?
#include <stdio.h>
int main()
{
char str[10] = "hello";
char *p = strrchr(str, 'l');
printf("%c\n", *(++p));
}
Answer: B
Correct answer: o
strrchr finds the last 'l', which in hello is at index 3. The pre-increment moves the pointer on one, to index 4, and that character is o.
Please log in or register to report this question.