i have the following code...according to my book both the files should open...but it opens both the files...writes into them....but when i open them for reading....only one opens up....pls see where i am wrong....
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream fout;
fout.open("country.txt");
fout<<"United States of America\n";
fout<<"United Kingdom\n";
fout<<"South Korea\n";
fout.close();
fout.open("capital.txt");
fout<<"Washington\n";
fout<<"London\n";
fout<<"Seoul\n";
fout.close();
const int n= 80;
char line[n];
ifstream fin;
cout<<"\nContents of capital file\n";
fin.open("capital.txt",ios::in);
fin.getline(line, n);
cout<<line;
}while(fin);
fin.close();
fin.open("country.txt");
cout<<"\nContents of country file";
do
{
fin.getline(line, n);
cout<<line;
}while(fin);
fin.close();
system("pause");
}