C ++ 11,从字符串流读取字符会返回最后一个字符两次

时间:2020-06-26 15:48:24

标签: stringstream

所以我要逐字符读取字符串流,因为我想将其内容复制到特定格式的另一个字符串中,问题是由于某种原因,我将流的最后一个字符复制了两次。这是代码

string infoTabella;
while(ss >> noskipws  >> c){
    if(c==44||c==40||c==41) {
        infoTabella += ' ';
        infoTabella += c;
        infoTabella += ' ';
    }else{
        infoTabella += c;
    }
}

当我到达流的末尾时,while条件不应该设置为false吗?

(对不起,英语不好,不是我的母语)

0 个答案:

没有答案
相关问题