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.