Oct 13, 2020 at 7:45pm UTC
Hello, I wonder what the difference is with these functions.
setf() - fmtflags setf(fmtflags flags) - says the function returns previous settings of flags and turns on the flags specified by flags
but i do no see much differ from the flags function which says
fmtflags flags(fmtflags flags) - sets the flag value to that specified by flags and returns the previous flag value
I do not understand the difference. I see one video and the person say the difference is flags() can take many parameters. Is this only difference?
Oct 13, 2020 at 8:02pm UTC
The one-parameter version of setf sets but does not unset flags.
The two parameter version replaces the masked flags.
flags replaces the current flags; it behaves like
stream.setf(flags, ~0);
If this doesn't make any sense, study bitfields .
Oct 13, 2020 at 8:20pm UTC
I think I understood. So if i used setf() i could set many different flags on different lines of code. But if i used flags() it would replace the previous flag set each time it was called.
Oct 13, 2020 at 8:27pm UTC
Great, thank you for help.