C++string字符串拼接

#include
#include
#include
using namespace std;

void splitString(const string& str,const string&s)
{
int pos = 0;
int flag = 0;
int num = str.size();
string tmp1;
string tmp2;
while( pos < str.size())
{
flag = str.find(s,pos);
if (flag == -1) {
for (int j=pos;j tmp1+=str[j];
}
cout<<“str:”< break;
}
for (int i = pos; i < flag; i++)
{
tmp2 += str[i];
}
cout<<“str:”< pos = flag+1;
tmp2="";
}
}

int main(int argc,char**args)
{
const char* str=“1,12”;
string str=“1,2,3,45555”;
string s=",";
splitString(str,s);

}`

你可能感兴趣的:(C++学习)