他の言語では split があるのに C++ にはないから作ってみました.
#include
#include
using namespace std;
vector split(string strOrg, string strDiv)
{
vector astrRet;
int iCnt;
int iFind;
for( iCnt = 0; iCnt <= strOrg.length(); iCnt = iFind + 1 ){
iFind = strOrg.find_first_of( strDiv, iCnt );
if( iFind == string::npos ) iFind = strOrg.length();
astrRet.push_back( strOrg.substr( iCnt, iFind - iCnt ) );
}
return astrRet;
}
参照