fstream reading file at C++ code example
Example 1: fstream in c++
#include<fstream>
int main()
{
fstream file;
/*if we use fstream then we need to specify at least one
parameter mode like ios::out or ios::in else the file will not open */
file.open("filename.txt", ios::out|ios::in);
/*all work with file*/
file.close();
return 0;
}
Example 2: file reading c++
int a, b;
ifstream bd;
myfile.open("file.txt");
if (myfile.is_open())
while (bd >> a >> b)
cout << a << b << endl;
else cout << "ERROR";