is there a easy way to reset all flags of ios?

Started by
3 comments, last by snk_kid 18 years, 8 months ago
Like to change back the fill('*') to a whitespace and change the width(10) back to default? I simply want to reset the whole thing.
Advertisement
Here's a link on C++ I/O.
My money is on the function "unsetf()".
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Quote:Original post by deadimp
Here's a link on C++ I/O.
My money is on the function "unsetf()".
yep, i know this function, but with it i have to use it for every single flag i want to clear. Well ok.

You could use copyfmt() with a fresh stream object, but that's probably overkill.

Or you might use boost's IO state saver to save and then restore the stream state.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by Jonus
I simply want to reset the whole thing.


I assume you mean format flags and not stream state flags you could do:

std::ios_base::fmtflags original_flags = my_stream.flags();// ... set format flags ...my_stream.flags(original_flags); // reset them back to default.



This topic is closed to new replies.

Advertisement