Skip to content Tutorials Student Jobs Courses Write Come write articles for us and get featured Practice Learn and code with the best industry experts Premium Get access to ad-free content, doubt assistance and more! Jobs Come and find your dream job with us o o o o o o Geeks Digest Quizzes Geeks Campus Gblog Articles IDE Campus Mantri My Profile Edit Profile My Courses Go Premium o o o o o o o o o o o o o o o o o o Logout Home Courses Practice DS & Algo. Algorithms Analysis of Algorithms Data Structures Interview Corner Languages ISRO CS GATE CS Subjects Web Technologies School Learning Mathematics Maths Notes (Class 8-11) NCERT Solutions RD Sharma Solutions UGC NET CS Student Jobs GBlog Puzzles What's New ? Change Language Related Articles Related Articles Strings in C How to Append a Character to a String in C strncat() function in C/C++ strpbrk() in C strcoll() in C/C++ ispunct() function in C strspn() function in C isalpha() and isdigit() functions in C with cstring examples. static_cast in C++ | Type Casting operators const_cast in C++ | Type Casting operators reinterpret_cast in C++ | Type Casting operators Type Conversion in C++ Converting Strings to Numbers in C/C++ Converting string to number and vice-versa in C++ How to find size of array in C/C++ without using sizeof ? array::size() in C++ STL What are the default values of static variables in C? Understanding “volatile” qualifier in C | Set 2 (Examples) Const Qualifier in C Initialization of static variables in C Understanding “register” keyword in C Understanding “extern” keyword in C Storage Classes in C Static Variables in C Memory Layout of C Programs What is Memory Leak? How can we avoid? std::sort() in C++ STL Arrays in C/C++ Bitwise Operators in C/C++ Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc() strpbrk() in C Difficulty Level : Easy Last Updated : 02 May, 2018 This function finds the first character in the string s1 that matches any character specified in s2 (It excludes terminating null-characters). Syntax : char *strpbrk(const char *s1, const char *s2) Parameters : s1 : string to be scanned. s2 : string containing the characters to match. Return Value : It returns a pointer to the character in s1 that matches one of the characters in s2, else returns NULL. // C code to demonstrate the working of // strpbrk #include <stdio.h> #include <string.h> // Driver function int main() { // Declaring three strings char s1[] = "geeksforgeeks"; char s2[] = "app"; char s3[] = "kite"; char* r, *t; // Checks for matching character // no match found r = strpbrk(s1, s2); if (r != 0) printf("First matching character: %c\n", *r); else printf("Character not found"); // Checks for matching character // first match found at "e" t = strpbrk(s1, s3); if (t != 0) printf("\nFirst matching character: %c\n", *t); else printf("Character not found"); return (0); } Output: Character not found First matching character: e Practical Application This function can be used in game of lottery where the person having string with letter coming first in victory wins, i.e. this can be used at any place where first person wins. // C code to demonstrate practical application // of strpbrk #include <stdio.h> #include <string.h> // Driver function int main() { // Initializing victory string char s1[] = "victory"; // Declaring lottery strings char s2[] = "a23"; char s3[] = "i22"; char* r, *t; // Use of strpbrk() r = strpbrk(s1, s2); t = strpbrk(s1, s3); // Checks if player 1 has won lottery if (r != 0) printf("Congrats u have won"); else printf("Better luck next time"); // Checks if player 2 has won lottery if (t != 0) printf("\nCongrats u have won"); else printf("Better luck next time"); return (0); } Output: Better luck next time Congrats u have won This article is contributed by Shantanu Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C. Like6 Previous strncat() function in C/C++ Next strcoll() in C/C++ ADVERTISEMENT BY ADRECOVER RECOMMENDED ARTICLES Page : 1 2 Program to perform a letter frequency attack on a monoalphabetic substitution cipher 22, Jul 21 Implementing Sets Without C++ STL Containers 20, Jul 21 C/C++ program to implement the cricket game 20, Jul 21 How to create Binary File from the existing Text File? 20, Jul 21 Program that allows integer input only 20, Jul 21 Map Policy Based Data Structure in g++ 19, Jul 21 Recursive lambda expressions in C++ 19, Jul 21 Object Delegation in C++ 19, Jul 21 Creating a C++ reusable Header File and its Implementation Files 19, Jul 21 C Library Functions 18, Jul 21 Removed Features of C++17 16, Jul 21 Different ways to print elements of vector 16, Jul 21 Article Contributed By : GeeksforGeeks Vote for difficulty Current difficulty : Easy EasyNormalMediumHardExpert Improved By : SACHIN KUNTE Article Tags : C-Library cpp-string C Language C++ Practice Tags : CPP Improve Article Report Issue ADS BY ADRECOVER WHAT'S NEW Competitive Programming Live Classes for Students View Details DSA Self Paced Course View Details DSA Live Classes for Working Professionals View Details ADS BY ADRECOVER MOST POPULAR IN C LANGUAGE Core Dump (Segmentation fault) in C/C++ Left Shift and Right Shift Operators in C/C++ Substring in C++ Multidimensional Arrays in C / C++ Structures in C ADS BY ADRECOVER MOST VISITED IN C++ Vector in C++ STL The C++ Standard Template Library (STL) Map in C++ Standard Template Library (STL) Object Oriented Programming in C++ Inheritance in C++ ADS BY ADRECOVER Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here. Load Comments ADVERTISEMENT BY ADRECOVER 5th Floor, A-118, Sector-136, Noida, Uttar Pradesh - 201305 feedback@geeksforgeeks.org Company Learn Practice Contribute About Us Careers Privacy Policy Contact Us Copyright Policy Algorithms Data Structures Languages CS Subjects Video Tutorials Courses Company-wise Topic-wise How to begin? Write an Article Write Interview Experience Internships Videos @geeksforgeeks , Some rights reserved