C++ 문자열 find_last_of()

1 개요[ | ]

C++ 문자열 find_last_of()
#include <iostream>
using namespace std;
int main() {
	string s = "Hello World!";
	int pos = s.find_last_of("H");
	cout << pos << endl; // 0
	cout << s.find_last_of("l") << endl;    // 9
	cout << s.find_last_of("ll") << endl;   // 9
	cout << s.find_last_of("llll") << endl; // 9
	cout << s.find_last_of("e") << endl;    // 1
	cout << s.find_last_of("z") << endl;    // 18446744073709551615
}
#include <iostream>
#include <string>
#include <cstddef>
using namespace std;
void SplitFilename(const string& str) {
    size_t pos = str.find_last_of("/\\");
    cout << str.substr(0, pos) << ", " << str.substr(pos+1) << '\n';
}

int main () {
    SplitFilename("/usr/bin/man");             // /usr/bin, man
    SplitFilename("c:\\windows\\winhelp.exe"); // c:\windows, winhelp.exe
}

2 같이 보기[ | ]

3 참고[ | ]

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