ProgrammingModerate

char s[] = "hello world"; char *w = strchr(s, ' ') + 1; printf("%s", w); What is printed?

  1. A. world
  2. B. hello world
  3. C. hello
  4. D. w

Correct answer: A. world

strchr returns a pointer to the space, and adding 1 starts the output after it. The string literal's contents are copied into s, so the change is legal.

More C Programming questions

Exams that ask this topic