Using strpbrk
#include <iostream> #include <string.h> using namespace std; int main() { char *string1 = "This is a test"; 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; }