"C++ 문자열 find first of()"의 두 판 사이의 차이

(새 문서: ==개요== {{DISPLAYTITLE:C++ 문자열 find_last_of()}} ;C++ 문자열 find_last_of() <syntaxhighlight lang='cpp' run> #include <iostream> using namespace std; int main() { string...)
 
34번째 줄: 34번째 줄:


==같이 보기==
==같이 보기==
{{z컬럼3|
* [[C++ search()]]
* [[C++ for_each()]]
* [[C++ binary_search()]]
* [[C++ 문자열 rfind()]]
* [[C++ 문자열 rfind()]]
* [[C++ 문자열 substr()]]
* [[C++ 문자열 substr()]]
* [[C++ search()]]
* [[C++ 문자열 find_last_of()]]
* [[C++ binary_search()]]
* [[C++ for_each()]]
* [[함수 strpos()]]
* [[함수 strpos()]]
}}


==참고==
==참고==

2024년 1월 9일 (화) 17:14 판

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 }}