ProgrammingHard

char s[] = "banana"; char *p = strrchr(s, 'a'); printf("%ld", (long)(p - s)); What is printed?

  1. A. 5
  2. B. 1
  3. C. 3
  4. D. 4

Correct answer: A. 5

strrchr returns a pointer to the last 'a', which is at index 5. Subtracting the base address gives that index.

More C Programming questions

Exams that ask this topic