![]() |
![]() |
![]() |
Find one string inside another
#include <string.h> size_t strspn( const char* str, const char* charset );
libc
The strspn() function computes the length of the initial segment of the string pointed to by str that consists of characters from the string pointed to by charset. The terminating null character is not considered to be part of charset.
The length of the segment.
#include <stdio.h> #include <stdlib.h> #include <string.h> int main( void ) { printf( "%d\n", strspn( "out to lunch", "aeiou" ) ); printf( "%d\n", strspn( "out to lunch", "xyz" ) ); return EXIT_SUCCESS; }
produces the output:
2 0
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
![]() |
![]() |
![]() |