ProgrammingHard

const char *s = "abcabc"; printf("%ld", (long)(strstr(s, "ca") - s)); What is printed?

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

Correct answer: D. 2

strstr returns a pointer to the first occurrence of "ca", which starts at index 2. Subtracting s gives the index.

More C Programming questions

Exams that ask this topic