C Quiz: Strings & the Null Terminator

In C a string is just a char array that ends with a null character, '\0'. This quiz checks how that terminator affects sizeof, strlen and printf, and the classic mistakes with string literals.

मीडियम 10 सवाल ~6 मिनट पास होने के लिए 80% C17

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

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

int main(void) {
    char s[] = "hello";
    printf("%zu %zu\n", sizeof(s), strlen(s));
    return 0;
}
जवाब दिखाएं

D. 6 5 The array gets room for the 5 letters plus the terminating '\0', so sizeof(s) is 6. strlen counts characters before the terminator, so it is 5.

इस क्विज़ में क्या है

  • The hidden '\0' at the end of every string literal
  • sizeof vs strlen
  • Ending a string early by writing '\0'
  • Characters are small integers
  • Why string literals must not be modified

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।