C++ 문자열 find()

1 개요[ | ]

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

2 같이 보기[ | ]

3 참고[ | ]

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