How do you clear a stringstream variable?

后端 未结 8 1950
时光说笑
时光说笑 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:06

    It's a conceptual problem.

    Stringstream is a stream, so its iterators are forward, cannot return. In an output stringstream, you need a flush() to reinitialize it, as in any other output stream.

提交回复
热议问题