

- 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
How to append text to a text file in C++?
This is a C++ program to append text to a text file.
Algorithm
Begin Open that file a1.txt as output file stream class object to perform output operation in append mode using fout file reference. If the file exists then Appending text to that file. Close fout. Open the file “a1.txt” for reading the content of the file. Extracting the text from file and printing the text. End.
Example Code
#include<iostream> #include<string> #include<fstream> using namespace std; int main() { fstream f; ofstream fout; ifstream fin; fin.open("a1.txt"); fout.open ("a1.txt",ios::app); if(fin.is_open()) fout<<" tutorials point"; cout<<"\n Data has been appended to file"<<endl; fin.close(); fout.close(); string word; f.open("a1.txt"); while (f >> word) { cout << word << " "; } return 0; }
Output
Data has been appended to file
- Related Questions & Answers
- Java Program to Append Text to an Existing File
- C++ program to append content of one text file to another
- How to read a text file in Python?
- How can I append text to JTextArea in Java?
- How to read a text file with C++?
- How to write text and output it as a text file using R?
- How to open a plain text file in C#?
- How to open a plain text file in Java?
- How to work with a text file in Python?
- How to create a Python dictionary from text file?
- How to read a simple text file in Android App?
- How to read a text file in Selenium with python?
- How to write a text file in Selenium with python?
- How to read a text file from resources in Kotlin?
- Reading a Text file in java
Advertisements