C++ 문자열 find_last_of()

Jmnote (토론 | 기여)님의 2024년 1월 9일 (화) 17:13 판 (새 문서: ==개요== {{DISPLAYTITLE:C++ 문자열 find_last_of()}} ;C++ 문자열 find_last_of() <syntaxhighlight lang='cpp' run> #include <iostream> using namespace std; int main() { string...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ 문자열 find_last_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 }}