

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ program to append content of one text file to another
This is a C++ program to append the content of one text file to another.
Input
a.txt file contains “Tutorials” a1.txt file contains “point”
Output
Tutorialspoint
Algorithm
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.
Example Code
#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; }
Output
Tutorialspoint
- Related Questions & Answers
- Java Program to Append Text to an Existing File
- C program to copy the contents of one file to another file?
- 8086 program to add the content of one segment to another segment
- How to append text to a text file in C++?
- How to add/append content to an existing file using Java?
- C Program for copying the contents of one file into another file
- How to copy the content of one HTML5 Canvas to another Canvas locally?
- How to write a program to copy characters from one file to another in Java?
- How to read data from one file and print to another file in Java?
- Moving a file from one directory to another using Java
- How to make Animate text from one TextView to another in Android?
- How to move a file from one folder to another using Python?
- Change the focus from one Text widget to another in Tkinter
- Java Program to construct one String from another
- Java Program to Call One Constructor from another
Advertisements