8.Write a c++ program, which accepts two filename from command line appends the content of second file to first file. It should also display the content of the first file after appending.
/*J_5_P_8
Write a c++ program, which accepts two filename from command line
appends the content of second file to first file. It should also display the
content of the first file after appending.
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
fstream file;
ifstream ifile("file2.txt", ios::in);
ofstream ofile("file.txt", ios::out | ios::app);
if (!ifile.is_open()) {
cout << "file not found";
}
else {
ofile << ifile.rdbuf();
}
string word;
file.open("file2.txt");
while (file >> word) {
cout << word << " ";
}
return 0;
}
Comments
Post a Comment