clear
Syntax:
  #include <fstream>
  void clear( iostate flags = ios::goodbit );

The function clear() does two things:

  • it clears all io stream state flags associated with the current stream,
  • and sets the flags denoted by flags

The flags argument defaults to ios::goodbit, which means that by default, all flags will be cleared and ios::goodbit will be set.