The strlen () function in C
The function size_t strlen (const char * str) calculates the length of str string (not including the ending null character).
The function size_t strlen (const char * str) calculates the length of str string (not including the ending null character).
Declare the strlen () function in C
Here is the declaration for strlen () in C:
size_t strlen ( const char * str )
Parameters
str - Is a string to find the length.
Returns the value
This function returns the length of the string.
For example
The following program C illustrates the usage of strlen () in C:
#include #include int main () { char str [ 50 ]; int len ; strcpy ( str , "Hoc C co ban va nang cao tai QTM !!!" ); len = strlen ( str ); printf ( "Do dai cua chuoi:n |%s| nla bang:n |%d|n" , str , len ); return ( 0 ); }
Compile and run the above C program to see the results:
According to Tutorialspoint
Previous article: strerror () function in C
Next lesson: strpbrk () function in C
4 ★ | 1 Vote
You should read it
- The strchr () function in C
- The strerror () function in C
- The strcspn () function in C
- How to 'survive' with the stress of learning programming
- Strncat () function in C
- The strtok () function in C
- The strncpy () function in C
- Bookmark a few tricks to help you master a programming language
- Top 20 free programming learning websites need to bookmark immediately!
- Beginners of computer programming need to focus on what?
- The strspn () function in C
- Set of multiple choice questions about programming with P10 prize
Maybe you are interested
Traveling with Kids: How to Make Your Trip Fun and Stress-Free
Instructions for recording live video on ChatGPT Voice
One Piece: Strength Ranking of Straw Hat Crew Members
Instructions for inserting stickers into photos on iPhone
FBI Warns iMessage Is Not a Strongly Encrypted Messaging App
Google Labs Releases Whisk: A Tool That Allows You to Upload Images as Instructions Instead of Text Prompts