The strspn() function returns the length of the initial substring of the string pointed to by str1 that is made up of only those character contained in the string pointed to by str2.
size_t strspn(const char *str1, const char *str2) str1 : string to be scanned. str2 : string containing the characters to match. Return Value : This function returns the number of characters in the initial segment of str1 which consist only of characters from str2.
Length of initial segment matching 4
Length of initial segment matching 0
This article is contributed by Shivani Ghughtyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- How to return multiple values from a function in C or C++?
- strpbrk() in C
- strcoll() in C/C++
- # and ## Operators in C
- ispunct() function in C
- Anything written in sizeof() is never executed in C
- Difference between while(1) and while(0) in C language
- isalpha() and isdigit() functions in C/C++ with example
- Converting Strings to Numbers in C/C++
- Different methods to reverse a string in C/C++
- How to use getline() in C++ when there are blank lines in input?
- Scope rules in C
- Data type of case labels of switch statement in C++?
- C function to Swap strings
- Change/add only one character and print '*' exactly 20 times