Lesson 16 of 23

Strings: Character Arrays

11 min 30 XP

C मध्ये string म्हणजे '\0' (null character) ने संपणारा char array. "Hi" प्रत्यक्षात 3 bytes घेते: 'H', 'i', '\0'. <string.h> strlen, strcpy, strcat आणि strcmp देते.

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Spaces सह संपूर्ण ओळ वाचण्यासाठी fgets वापरा. ते शेवटचा \n ठेवते, जो strcspn ने काढता येतो.

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Strings ची तुलना == ने करता येत नाही (ते addresses ची तुलना करते). strcmp(a, b) == 0 म्हणजे दोन्ही समान.

Challenge

+30 XP

fgets ने एक ओळ वाचा आणि तिचे vowels, consonants आणि spaces मोजा. Input: Hello World Output: Vowels: 3 Consonants: 7 Spaces: 1

Output Loading C (first time takes a few seconds)
Press Run to see the result here.