-
What is the output of this program?
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ofstream outfile ("Sample.txt");
for (int num = 0; num < 50; num++)
{
outfile << num;
outfile.flush();
}
cout << "Done successfully";
outfile.close();
return 0;
}
-
- compilation Error
- Runtime Error
- Garbage value
- Done successfully
- None of these
Correct Option: D
In this program, We are using the flush function to update the contents in a file.