Write a code to open a file to write into it Check to see if

Write a code to open a file to write into it. Check to see if it opens, then write an integer in to the file.

Solution

Answer:

#include<iostream.h>

#include<conio.h>

#include<fstream.h>

clrscr();

ofstream of s;

int a;

ofs.open(\"abc.txt\");

if(ofs)

{

cout<<\"enter integer=\";

cin>> a;

ofs<<a;

cout<<\"\ \ \"<<a<<\" integer has been written into the file\";

}

getch();

}

Write a code to open a file to write into it. Check to see if it opens, then write an integer in to the file.SolutionAnswer: #include<iostream.h> #include

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site