본문 바로가기

C/C++

C++11 Stringtokenizer

C++11 Stringtokenizer


간단한 구현. 요긴하게 쓰자


#ifndef __STRINGTOKEN_UTIL__
#define __STRINGTOKEN_UTIL__
#include <vector>
#include <string>
using namespace std;

vector<string> split(const char *str, char c = ' ')
{
vector<string> result;

do
{
const char *begin = str;


while (*str != c && *str)
str++;

result.push_back(string(begin, str));
} while (0 != *str++);

return result;
}
#endif // !__STRINGTOKEN_UTIL__


StringtokenUtil.h


'C/C++' 카테고리의 다른 글

C++ Casting  (0) 2015.10.17
개미수열  (0) 2015.03.04
C++11 강제  (0) 2015.01.26
Eclise CDT C++11지원  (0) 2015.01.26
cin 입력 에러 해결법  (0) 2013.10.20