#include <iostream>
#include <vector>
using namespace std;
vector<string> Char2Token(const char* szSent){
vector<string> tokens;
int i = 0;
while (szSent[i] != '\0')
{
if (szSent[i]<0){//汉字
char szTmp[4];// = {0};
szTmp[0] = szSent[i];
szTmp[1] = szSent[i+1];
szTmp[2] = szSent[i+2];
szTmp[3] = 0;
string strTmp(szTmp);
tokens.push_back(strTmp);
i+=3;
}else{
char szTmp[3] = {0};
szTmp[0] = szSent[i];
string strTmp(szTmp);
tokens.push_back(strTmp);
i++;
}
}
return tokens;
}
int main(int argc, char const *argv[])
{
char ch0[]={"金古江湖战旗春秋"};
vector<string> vec_str0 = Char2Token(ch0);
for(int i=0; i<vec_str0.size(); i++)
{
cout<<vec_str0[i]<<endl;
}
cout<<endl;
cout<<endl;
char ch1[]={"金古江湖 战旗春秋"};
vector<string> vec_str1 = Char2Token(ch1);
for(int i=0; i<vec_str1.size(); i++)
{
cout<<vec_str1[i]<<endl;
}
cout<<endl;
cout<<endl;
char ch2[]={"金古江湖A战旗春秋"};
vector<string> vec_str2 = Char2Token(ch2);
for(int i=0; i<vec_str2.size(); i++)
{
cout<<vec_str2[i]<<endl;
}
return 0;
}