strpbrk() in C

CProgrammingServer Side Programming

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,


 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\n", *result);


The matching character : l
Updated on 24-Jun-2020 11:16:33