C++ 문자열 find_first_of()

1 개요[ | ]

C++ 문자열 find_first_of()
#include <iostream>
using namespace std;
int main() {
	string s = "Hello World!";
	int pos = s.find_first_of("H");
	cout << pos << endl; // 0
	cout << s.find_first_of("l") << endl;    // 2
	cout << s.find_first_of("ll") << endl;   // 2
	cout << s.find_first_of("llll") << endl; // 2
	cout << s.find_first_of("e") << endl;    // 1
	cout << s.find_first_of("z") << endl;    // 18446744073709551615
}
#include <iostream>
#include <string>
#include <cstddef>
using namespace std;
int main () {
  string str ("Please, replace the vowels in this sentence by asterisks.");
  size_t found = str.find_first_of("aeiou");
  while (found!=string::npos) {
    str[found]='*';
    found=str.find_first_of("aeiou",found+1);
  }
  cout << str << '\n';
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}