Easy File handling in C++ (working with files, fstream)
In this tutorial, we are working with the files in the C++ or you have known to work with files as the file handling. File handling in any language requires Three main step to follow Open the file in Read/Write mode. Do various operation that you want to do. Close the file. So In CPP, you can also use the traditional approach of C using FILE pointer and etc. We are using fstream (file stream). Without wasting much time lets start working. Create a New CPP file of whatever name you want mine is files.cpp. create the basic schema of cpp. #include <iostream> using namespace std; int main() { return 0; } To work with file add two more header first is #include<fstream> , and second is #include<string> #include <fstream> #include <string> Now, let's start working with the writing into the files, to write into the file we need to open the file into the Write mode. Which can be done by the ofstream class of cpp from the fstream header. string