Skills101
← All practice quizzes

Quiz: String Handling in C

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Go beyond strlen and strcpy. Write the classic string functions yourself with pointers, learn why a string literal cannot be changed, split text with strtok, build and parse strings with sprintf and sscanf, and solve the standard string programs.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    #include <stdio.h>
    int len(const char *s) {
        const char *p = s;
        while (*p) p++;
        return (int)(p - s);
    }
    int main(void) {
        printf("%d", len("Skills101"));
        return 0;
    }
    
  2. Question 2

    What is wrong with char *s = "hello"; s[0] = 'H';?

  3. Question 3

    strcmp("apple", "apply") returns:

  4. Question 4

    What does this print?

    #include <stdio.h>
    int main(void) {
        char a[] = "exam";
        printf("%d", (int)sizeof(a));
        return 0;
    }
    
  5. Question 5

    Why is snprintf preferred over sprintf?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →