C++ 문자열 rfind()

Jmnote (토론 | 기여)님의 2023년 9월 22일 (금) 02:25 판 (새 문서: ==개요== ;C++ find() <syntaxhighlight lang='cpp' run> #include <iostream> using namespace std; int main() { string s = "Hello World!"; cout << s.rfind("l") << endl; // 9 cout...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ find()
#include <iostream>
using namespace std;
int main() {
	string s = "Hello World!";
	cout << s.rfind("l") << endl;   // 9
	cout << s.rfind("ll") << endl;  // 2
	cout << s.rfind("lll") << endl; // 18446744073709551615
	cout << s.rfind("z") << endl;   // 18446744073709551615
}
#include <iostream>
using namespace std;
int main() {
	string s = "Hello World!";
	cout << (s.rfind("ll") != string::npos) << endl; // 1 (exits)
	cout << (s.rfind("dd") != string::npos) << endl; // 0 (not exists)
}

2 같이 보기

3 참고

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