C strpbrk() Function

C strpbrk() Function

The strpbrk() function searches the first occurrence of the character in a given string and then it displays the string starting from that character.

Example

C Compiler
#include <stdio.h> #include <string.h> int main() { char str1[] = "wikimass.com"; char str2[] = "msi"; char *ptr; ptr = strpbrk(str1, str2); if(ptr) { printf("First matching character: %c\n", *ptr); printf("New String: %s", ptr); } else { printf("Character not found"); } return 0; }

Syntax

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

Parameter Values

ValueTypeExplanation
str1RequiredSpecifies an actual string
str2RequiredSpecifies a string of characters to be searched in str1.

Return Value

ValueExplanation
AddressReturns the pointer position to the first occurrence of the character (str2) in the string (str1).
NULLIf no occurrence of the character (str2) in the string (str1).

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author