Tail of a File, C++ Program.
write a program that asks the user for the name of a text file. Theprogram should display the last 10 lines, or all lines if less than10. The program should do this using seekg
Here is what I have so far.
#include
#include
#include
using namespace std;
class File
{
private:
  fstream file;
  string name;
public:
  int countlines();
  void printlines();
};
int File::countlines()
{
  int total = 0;
  file.open(\"Text.txt\");
  if (file)
  {
     do total = 1
  }
  while (getline(file, filename))
  {
  else
     cout << \"The file did notopen\" << endl;
  total -= 1;
  file.close;
  return total;
  }
}
void File::printlines()
{
  file.open(\"text.txt\");
  string data;
  int total = countlines();
  if (total <= 10)
     while (getline(file, data))
     {
        cout <     }
  return;
  if (total > 10)
  {
     file.seekg(0L, ios::beg);
     int position = total - 10;
     int linecount = 0
        do
        {
           linecount = 1;
           if (position + 1) == linecount)
           {
           getline(file, data)
              while (file.fail(1))
              {
                 cout<< data << endl;
                 getline(file, data);
              }
           }
        }
     while (getline(file, data));
        file.close;
  }
}