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 ಎಂದರೆ ಅವು ಸಮ.