Answers for "how to use flush in cpp"

0

how to use flush in cpp

// Flushing files (flush manipulator)
#include <ostream>      // std::flush
#include <fstream>      // std::ofstream

int main () {

  std::ofstream outfile ("test.txt");

  for (int n=0; n<100; n++)
    outfile << n << std::flush;

  outfile.close();

  return 0;
}
Posted by: Guest on May-28-2021

Browse Popular Code Answers by Language