resetting a stringstream

前端 未结 3 1419
温柔的废话
温柔的废话 2020-12-02 15:11

How do I \"reset\" the state of a stringstream to what it was when I created it?

int firstValue = 1;
int secondValue = 2;

std::wstringstream ss;

ss <<         


        
3条回答
  •  醉话见心
    2020-12-02 15:51

    This is the way I usually do it:

    ss.str("");
    ss.clear(); // Clear state flags.
    

提交回复
热议问题