C++ ЧТЕНИЕ ИЗ ФАЙЛА

cd ~/

nano file-reader.cpp

#include "iostream"
#include "fstream"
#include "string"
using namespace std;

int main () {
  string line;
  ifstream myfile ("example.txt");
  if (myfile.is_open())
  {
    while ( getline (myfile,line) )
    {
      cout << line << '\n';
    }
    myfile.close();
  }
  else cout << "Unable to open file"; 
  return 0;
}
}

sudo g++ -Wall -o file-reader file-reader.cpp

./file-writer