strpbrk function searches string for given characters

Syntax

C strpbrk function has the following format.

char *strpbrk(const char *str1, const char *str2);

C strpbrk function is from header file string.h.

Description

C strpbrk function returns a pointer to the first character in *str1 that matches any character in *str2.

If there are no matches, a null pointer is returned.

Example

Use C strpbrk function to search string for characters.


#include <stdio.h>
#include <string.h>
// ww  w  .  j  ava 2 s .co  m
int main(void)
{
  char *p;

  p = strpbrk("this is a test", " absj");
  printf(p);

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h