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 firstname.lastname@example.org. 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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- How to call function within function in C or C++
- arc function in C
- Inline function in C
- putchar() function in C
- c16rtomb() function in C/C++
- c32rtomb() function in C/C++
- wcsrchr() function in C/C++
- mbrtowc() function in C/C++
- wcspbrk() function in C/C++
- iswctype() function in C/C++
- strtoumax() function in C++
- wctype() function in C/C++
- strtoimax() function in C++
- mbrlen() function in C/C++
- strcmpi() function in C
- gmtime() Function in C/C++
- towupper() function in C/C++
- iswpunct() function in C/C++
- wcstoll() function in C/C++
- iswalnum() function in C++ STL