我想要根据0x1d
cahr分隔符切换到子串的字符串。如何告诉istringstream
它必须在0x1d
操作期间根据>>
分隔符提取字符?
string s("Somewhere"+string(1,0x1d)+"down"+string(1,0x1d)+"the"+string(1,0x1d)+"road");
istringstream iss(s);
do
{
string sub;
iss >> sub;
cout << "Substring: " << sub << endl;
} while (iss);
答案 0 :(得分:0)
您得到回复Here
来自@jrok
std::string input = "abc,def,ghi";
std::istringstream ss(input);
std::string token;
while(std::getline(ss, token, ',')) {
std::cout << token << '\n';
}