How do I empty the stringstream variable?

Asked 2 years ago, Updated 2 years ago, 125 views

I tried it like the source code below, but it didn't work ㅜㅜ What should I do?

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

c++ stringstream

2022-09-22 22:34

1 Answers

The emtpy() member function in the standard library is query, not command. What it means is, empty empty()! Is it empty?That's what it means.

The clear() member function is written to clear the error state from the stream. For example Error state - When eofbit(end-of-file) is 1 When clear() is invoked, eofbit is set to 0.

To empty stringstream, write:


2022-09-22 22:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.