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

 
(같은 사용자의 중간 판 2개는 보이지 않습니다)
10번째 줄: 10번째 줄:
int pos = s.find_last_of("H");
int pos = s.find_last_of("H");
cout << pos << endl; // 0
cout << pos << endl; // 0
cout << s.find_last_of("l") << endl;   // 9
cout << s.find_last_of("l") << endl;   // 9
cout << s.find_last_of("ll") << endl; // 9
cout << s.find_last_of("ll") << endl;   // 9
cout << s.find_last_of("lll") << endl; // 9
cout << s.find_last_of("llll") << endl; // 9
cout << s.find_last_of("e") << endl;   // 1
cout << s.find_last_of("e") << endl;   // 1
cout << s.find_last_of("z") << endl;   // 18446744073709551615
cout << s.find_last_of("z") << endl;   // 18446744073709551615
}
}
</syntaxhighlight>
</syntaxhighlight>
34번째 줄: 34번째 줄:


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


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

2024년 1월 9일 (화) 17:15 기준 최신판

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