यह एक टेक्स्ट फ़ाइल की सामग्री को दूसरे में जोड़ने के लिए एक C++ प्रोग्राम है।
इनपुट
a.txt file contains “Tutorials” a1.txt file contains “point”
आउटपुट
Tutorialspoint
एल्गोरिदम
Begin Define a fstream class object as fin. Open a input file a.txt with input file stream class object fin. Open a output file a1.txt with output file stream class object fout in append mode. Check if the file is not existing then Print “File not found”. Else append content from fin to fout. Open the destination file in read mode. Display its content as output. End.
उदाहरण कोड
#include <bits/stdc++.h> #include<fstream> using namespace std; int main() { fstream f; ifstream fin; fin.open("a.txt"); ofstream fout; fout.open("a1.txt", ios::app); if (!fin.is_open()) { cout << "Tutorialspoint"; } else { fout << fin.rdbuf(); } string word; f.open("a1.txt"); while (f >> word) { cout << word << " "; } return 0; }
आउटपुट
Tutorialspoint