- 论坛徽章:
- 0
|
#include <iostream>;
#include <fstream>;
#include <iomanip>;
using namespace std;
int main()
{
string str1,str2;
char temp[100],buffer[100];
ifstream openFile;
ofstream writeFile;
while(1)
{
cout << "Enter a input file name: ";
cin >;>;str1;
openFile.open(str1.c_str());
if (!openFile)
{
cout<< "Error in opening the input file! \n\n";
openFile.clear();
}
else
break;
}
while(1)
{
cout << "Enter a output file name: ";
cin >;>; str2;
writeFile.open(str2.c_str(),ios::app);
if (!writeFile)
{
cout<< "Error in opening the input file! \n\n";
openFile.clear();
}
else
break;
}
while (openFile.getline(buffer,100))
writeFile << buffer;
openFile.close();
writeFile.close();
return 0;
} |
|