void Tokenize(const string& str,
vector<string>& tokens,
const string& delimiters = " ")
{
// 맨 첫 글자가 구분자인 경우 무시
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// 구분자가 아닌 첫 글자를 찾는다
string::size_type pos = str.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos)
{
// token을 찾았으니 vector에 추가한다
tokens.push_back(str.substr(lastPos, pos - lastPos));
// 구분자를 뛰어넘는다. "not_of"에 주의하라
lastPos = str.find_first_not_of(delimiters, pos);
// 다음 구분자가 아닌 글자를 찾는다
pos = str.find_first_of(delimiters, lastPos);
}
}
여기서 while (string::npos != pos || string::npos != lastPos) 이 부분 뜻이 머임?
eof가 -1이거든? !eof라고 생각해
그럼 eof쓰던 npos 쓰던 똑같은 거임?
npos는 걍 상수야
!= npos가 != eof랑 같다고 생각하면 댐
오호 ㄱㅅㄱㅅ 땡큐