The function strpbrk () in C
Char * strpbrk (const char * str1, const char * str2) finds the first character in str1 string that connects any character specified in str2. (not including null ending characters).
Char * strpbrk (const char * str1, const char * str2) finds the first character in str1 string that connects any character specified in str2. (not including null ending characters).
Declaring the strpbrk () function in C
Below is the declaration for strpbrk () in C:
char * strpbrk ( const char * str1 , const char * str2 )
Parameters
str1 - Is a string to be scanned.
str2 - String containing characters to be matched.
Returns the value
This function returns a pointer to the character in str1 that connects (matches) to one of str2's characters, or returns NULL if no such character is found.
For example
The following C program illustrates the usage of strpbrk () in C:
#include #include int main () { const char str1 [] = "abcde2fghi3jk4l" ; const char str2 [] = "34" ; char * ret ; ret = strpbrk ( str1 , str2 ); if ( ret ) { printf ( "Ky tu ket noi dau tien: %cn" , * ret ); } else { printf ( "Khong tim thay ky tu" ); } return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Previous article: strlen () function in C
Next lesson: Strrchr () function in C
You should read it
- Memset () function in C
- The strrchr () function in C
- Strcpy () function in C
- Memmove function in C
- Function strxfrm () in C
- The strcoll () function in C
- The function strcmp () in C
- The function strncmp () in C
- The strstr () function in C
- The strtok () function in C
- Strcat function in C
- The strlen () function in C
Maybe you are interested
Revealing new findings about the size of the galaxy Admire incredibly detailed images of the Orion Nebula through the eyes of the James Webb telescope This star 'tears up' its companion to create a rare beautiful nebula Galaxy merger moment gives glimpse into Milky Way's future Science has discovered the fastest-flying star in the Milky Way, reaching 8% of the speed of light Discovered organic molecules that can make life in the center of the Milky Way