How do you clear a stringstream variable?

后端 未结 8 2081
时光说笑
时光说笑 2020-11-22 13:53

I\'ve tried several things already,

std::stringstream m;
m.empty();
m.clear();

both of which don\'t work.

8条回答
  •  时光说笑
    2020-11-22 14:16

    These do not discard the data in the stringstream in gnu c++

        m.str("");
        m.str() = "";
        m.str(std::string());
    

    The following does empty the stringstream for me:

        m.str().clear();
    

提交回复
热议问题