Lesson 16 of 23

Strings: Character Arrays

11 min 30 XP

C में string एक char array है जो '\0' (null character) पर खत्म होता है। "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.