STL String에서 문자열 자르기

template <typename Outit> 
int split(const std::wstring &pattern, const std::wstring &subject, Outit Dest){
	std::wstring::size_type pattern_length = pattern.length();   
	std::wstring::size_type beginpos = 0;   
	std::wstring::size_type endpos = subject.find(pattern);   
	while (endpos != std::wstring::npos){   
		*Dest = subject.substr(beginpos, endpos-beginpos);   
		beginpos = endpos + pattern_length;   
		endpos = subject.find(pattern, beginpos);   
	*Dest = subject.substr(beginpos);   
	return 0;   

필요 함수

std::list<std::wstring> result;   
split( L"\n", tmpStr, back_inserter(result));  // 구분자: \n, 원본문자열 tmpStr
for( auto i=result.begin(); i != result.end(); i++){
	std::wstring str = (*i);

실제 사용하는곳

댓글 달기

이메일 주소는 공개되지 않습니다.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.