Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given an initialized variable fileName, write a sequence of statements that crea

ID: 3665382 • Letter: G

Question

Given an initialized variable fileName, write a sequence of statements that create a file whose name is given by the variable and whose content is a single line consisting of "This Is File: " followed by the name of the file. Make sure that the data written to the file has been flushed from its buffer and that any system resources used during the course of running these statements have been released. (Do not concern yourself with any possible exceptions here-- assume they are handled elsewhere.)

Explanation / Answer

#include<iostreams.h>
#include<conio.h>
#include<fstream.h>

void main()
{
   char fileName[]="myfile";

   ofstream outf(fileName);

   clrscr();

   outf<<"This Is File: "<<fileName;

   flush(outf);
   outf.close();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote