File handling in C++
Files are important feature in any programming language. File handling refers to reading and writing information in the files. Files have some formats like .txt,.csv and so on. C++ has lot of standard library files to handles file management. Eg: < fstream > header file has ofstream , ifstream ,fstream. It also has ifstream(input file stream) and ofstream(output file stream). Let us create objects and open the file as follows… Eg: ‘ifstream’ : ifstream filein("sample .txt "); ‘ofstream’ : ofstream fileout("sample.txt"); Where filein ,fileout are objects accordingly. If you are using ‘fstream’, it needs to open a file like this. ‘fstream fstr("sample.text", mode);’ Here, fstr is the object of fstream. “sample.txt” is the file name. Mode is the purpose of operation going to be performed in the file. It has variety of types. Modes: ‘ ios::app ’ – append the contents to the en...