c++

解析字符串

c++

Posted by YiMiTuMi on August 19, 2020

解析用“;”间隔的字符串

void StringAnalysis(string cstr, vector<CString> &vecNewstr)
{
	string strSuffix = cstr;
	int iStrSave = 0;

	while(!strSuffix.empty())
	{
		iStrSave = strSuffix.find(";");
		if (iStrSave == strSuffix.npos)
		{
			break;
		}

		string strSave;
		strSave.insert(strSave.begin(), strSuffix.begin(), strSuffix.begin() + iStrSave);
		if (!strSave.empty())
		{
			vecNewstr.push_back(strSave.c_str());
		}
		strSave.clear();
		strSave.insert(strSave.begin(), strSuffix.begin() + iStrSave + 1, strSuffix.end());
		strSuffix = strSave;
	}
}

菖蒲 – 相信者的幸福