0

C++ を使用して、区切り記号を使用して文字列をトークン化し、while ループで cout を使用して現在のトークンを出力できます。私がしたいのは、トークンの現在の値を配列に格納して、後でアクセスできるようにすることです。ここに私が今持っているコードがあります:

string s = "Test>=Test>=Test";
string delimiter = ">=";
vector<string> Log;
int Count = 0;
size_t pos = 0;
string token;
while ((pos = s.find(delimiter)) != string::npos) {
token = s.substr(0, pos);
strcpy(Log[Count].c_str(), token.c_str());
Count++;

s.erase(0, pos + delimiter.length());
}
4

2 に答える 2

0

push_back()あなたが必要とすることをします。

于 2013-08-01T16:20:08.777 に答える