... value is 3.14159"};
 9     const char* string2{"1234567890"};
10
11     cout << "string1 = " << string1 << "\nstring2 = " << string2
12        << "\n\nThe length of the initial segment of string1"
13        << "\ncontaining no characters from string2 = "
14        << strcspn(string1, string2) << endl;
15  }

string1 = The value is 3.14159
string2 = 1234567890

The length of the initial segment of string1
containing no characters from string2 = 13

Function strpbrk searches for the first occurrence in its first string argument of any character in its second string argument. If a character from the second argument is found, strpbrk returns a pointer to the character in the first argument; otherwise, strpbrk returns a null pointer. Line 12 of Fig. 22.37 locates the first occurrence ...

Get C++ How to Program, 10/e now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.