You can do this by setting floatfield to null:
file1.setf( std::ios_base::fmtflags(), std::floatfield );
However, in practice this is rare. The usual protocol is to save format flags and restore them when you are done:
std::ios_base::fmtflags originalFlags = file1.flags();
Of course, you usually use RAII to do this in a real program. You must have an IOSave class in your toolbox that stores flags, precision, and the fill character in its constructor, as well as restoring them in the destructor.
Also not a good practice to use std::setprection etc. directly. A better solution would be to define your own manipulators, with names like pression or volume , and use them. This is logical markup and means that you control the format, for example. pressure from one and not spread it throughout the program. And if you write your own manipulators, it is relatively easy to restore the original formatting options at the end of the full expression. (The manipulator objects will be temporary, destroyed at the end of the full expression.)
source share