#include <iostream.h>
#include<stdio.h>
#include<conio.h>
#include <fstream.h>
int main()
{
// Creation of ofstream class object
ofstream fout;
fout.open("country.txt");
fout<<"India\n";
fout<<"USA\n";
fout<<"UK\n";
fout.close();
fout.open("capital.txt");
fout<<"Delhi\n";
fout<<"Washington\n";
fout<<"London\n";
fout.close();
const int N=80;
char line[N];
ifstream fin;
fin.open("country.txt");
cout<<"contents of country\n";
while(fin)
{
fin.getline(line,N);
cout<<line<<endl;
}
fin.close();
fin.open("capital.txt");
cout<<"contents of capitals\n";
while(fin)
{
fin.getline(line,N);
cout<<line<<endl;
}
fin.close();
getch();
return 0;
}
output:
0 Comments
Post a Comment