Using strpbrk searches for the first occurrence of a substring - C++ Data Type

C++ examples for Data Type:char array

Description

Using strpbrk searches for the first occurrence of a substring

Demo Code

#include <iostream> 
#include <cstring> // strpbrk prototype 
using namespace std; 

int main() /*from www.  ja va 2 s  . com*/
{ 
    const char *string1 = "This is a test"; 
    const char *string2 = "beware"; 

    cout << "Of the characters in \"" << string2 << "\"\n'" 
       << *strpbrk( string1, string2 ) << "\' is the first character " 
       << "to appear in\n\"" << string1 << '\"' << endl; 

    return 0;
}

Result


Related Tutorials