
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C library function - strpbrk()
Description
The C library function char *strpbrk(const char *str1, const char *str2) finds the first character in the string str1 that matches any character specified in str2. This does not include the terminating null-characters.
Declaration
Following is the declaration for strpbrk() function.
char *strpbrk(const char *str1, const char *str2)
Parameters
str1 − This is the C string to be scanned.
str2 − This is the C string containing the characters to match.
Return Value
This function returns a pointer to the character in str1 that matches one of the characters in str2, or NULL if no such character is found.
Example
The following example shows the usage of strpbrk() function.
#include <stdio.h> #include <string.h> int main () { const char str1[] = "abcde2fghi3jk4l"; const char str2[] = "34"; char *ret; ret = strpbrk(str1, str2); if(ret) { printf("First matching character: %c\n", *ret); } else { printf("Character not found"); } return(0); }
Let us compile and run the above program that will produce the following result −
First matching character: 3
string_h.htm
Advertisements