C string.h Functions Quiz

This C quiz covers the everyday functions from string.h and stdio.h for working with text. You will predict their results and spot the mistakes that cause wrong comparisons, missing terminators and overflows.

Medium 10 questions ~6 minutes Pass at 80% C17

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What does this print?

#include <stdio.h>
#include <string.h>

int main(void) {
    printf("%zu\n", strlen("hello world"));
    return 0;
}
Show the answer

C. 11 strlen counts every character before the terminator, including the space: 5 + 1 + 5 = 11. It does not count the '\0' itself, which is why 12 is wrong.

What this quiz covers

  • Length, copy and append: strlen, strcpy, strcat
  • Comparing with strcmp instead of ==
  • Searching with strchr and strstr
  • Why strncpy may leave out the terminator
  • Safe formatting with snprintf

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.