Check out example codes for "how to open an input file in c++". It will help you in understanding the concepts better.

Code Example 1

#include <fstream>

ifstream file_variable; //ifstream is for input from plain text files"input.txt"); //open input.txt

file_variable.close(); //close the file stream
Manually closing a stream is only necessary
if you want to re-use the same stream variable for a different
file, or want to switch from input to output on the same file.
//You can also use cin if you have tables like so:
while (cin >> name >> value)// you can also use the file stream instead of this
 cout << name << value << endl;
//ifstream file_variable; //ifstream is for input from plain text files
ofstream out_file;"output.txt");

out_file << "Write this scentence in the file" << endl;

Learn ReactJs, React Native from