共享两个项目文件

时间:2014-08-28 09:33:29

标签: c++

我想要根据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);

1 个答案:

答案 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';
}