strpbrk() in C


The function strpbrk() is used to find the first character of first string and matches it to any character of second string. It returns NULL, if no matches are found otherwise, it returns a pointer to the character of first string that matches to the character of second string.

Here is the syntax of strpbrk() in C language,

char *strpbrk(const char *string1, const char *string2)

Here is an example of strpbrk() in C language,

Example

 Live Demo

#include <stdio.h>
#include <string.h>
int main () {
   const char s1[] = "Helloworld";
   const char s2[] = "Blank";
   char *result;
   result = strpbrk(s1, s2);
   printf("The matching character : %c
", *result);    return(0); }

Output

The matching character : l

Updated on: 24-Jun-2020

919 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements