String

Método Find

Find character in string
Searches the string for the first character that matches any of the characters specified in its arguments.

When pos is specified, the search only includes characters at or after position pos, ignoring any possible occurrences before pos.

Notice that it is enough for one single character of the sequence to match (not all of them). See string::find for a function that matches entire sequences.

Ejemplo:
// string::find_first_of
#include <iostream>       // std::cout
#include <string>         // std::string
#include <cstddef>        // std::size_t

int main ()
{
  std::string str ("Please, replace the vowels in this sentence by asterisks.");
  std::size_t found = str.find_first_of("aeiou");
  while (found!=std::string::npos)
  {
    str[found]='*';
    found=str.find_first_of("aeiou",found+1);
  }

  std::cout << str << '\n';

  return 0;
}


La salida sería:

Pl**s*, r*pl*c* th* v*w*ls *n th*s s*nt*nc* by *st*r*sks.