Write down a
program to create a file temp.txt, write into the specific file than read the
same data from the file
|
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void
main()
{
int i,i1;
ofstream
of1("temp.txt");
for(i=1;i<=10;i++)
of1<<i<<" ";
of1.close();
cout<<"\n Read data
from file\n";
ifstream
if1("temp.txt");
for(int j=1;j<=10;j++)
{
if1>>i1;
cout<<i1<<" ";
}
if1.close();
}
|