ProgrammingHard

char w[] = "one two"; char *p = w; while (*p && *p != ' ') p++; printf("%d", (int)(p - w)); What is printed?

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

Correct answer: C. 3

The loop stops at the space, which is at index 3. The difference of the two pointers is that index.

More C Programming questions

Exams that ask this topic