#include #include using std::string;using std::vector;int splitStringToVect(const string & srcStr, vector & destVect, const string & strFlag);int main(){ string str = "asdasdas \n, sadasd\n, ssdddsrr\n \n \n ss\n"; vector destVect; splitStringToVect(str, destVect, "\n"); //以"\n"为标记,分割字符串到vector中 return 1;}int splitStringToVect(const string & srcStr, vector & destVect, const string & strFlag){ int pos = srcStr.find(strFlag, 0); int startPos = 0; int splitN = pos; string lineText(strFlag); while (pos > -1) { lineText = srcStr.substr(startPos, splitN); startPos = pos + 1; pos = srcStr.find(strFlag, pos + 1); splitN = pos - startPos; destVect.push_back(lineText); } lineText = srcStr.substr(startPos, srcStr.length() - startPos); destVect.push_back(lineText); return destVect.size();}