Mega Code Archive

 
Categories / C++ / String
 

Equivalent of strspn()

#include <iostream> #include <string> using namespace std; int main( ) {    string typing( "The quick, brown fox jumps over the lazy dog" );    cout << "String:  " << typing << endl;    // equivalent of strspn()    string::size_type index = typing.find_first_not_of( "aeiou" );        if( index != string::npos )       cout << "\nThe first letter that is not a lower-case vowel "          "is at index " << index;    else       cout << "\nAll letters in the string are lower-case vowels"; }