Given source and destination text files. Append the content from source file to destination file and then display the content of destination file.
Input : file.txt : "geeks", file2.txt : "geeks for" Output: file2.txt : "geeks for geeks"
1) Open file.txt in inputstream and file2.txt in outputstream with append option, so that the previous content of file are not deleted.
2) Check if there’s an error in opening or locating a file. If yes, then throw an error message.
3) If both the files are found, then write content from source file to destination file.
4) Display the content of destination file.
geeks for geeks
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- C program to copy contents of one file to another file
- Reverse the content of a file and store it in another
- C++ program to modify the content of a Binary File
- C++program to delete the content of a Binary File
- lseek() in C/C++ to read the alternate nth byte and write it in another file
- Write a C program that displays contents of a given file like 'more' utility in Linux
- C Program to count number of lines in a file
- C Program to print contents of file
- C Program to merge contents of two files into a third file
- C program to delete a file
- C++ program to print unique words in a file
- C++ program to read file word by word
- Program to delete a line given the line number from a file
- C Program to find size of a File
- C++ program to create a file
- How to convert a class to another class type in C++?
- How to print Colored text in C++
- fopen() for an existing file in write mode
- Implement your own tail (Read last n lines of a huge file)
- Four File Handling Hacks which every C/C++ Programmer should know
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.