Source of test_displaytextfile.cpp


  1: //test_displaytextfile.cpp
  2: //A test driver for the Scobey:DisplayTextfile() free function.

  4: #include <iostream>
  5: #include <string>
  6: using namespace std;

  8: #include "utilities.h"
  9: using Scobey::DisplayTextfile;
 10: using Scobey::Pause;

 12: int main()
 13: {
 14:     Pause(0, "\nTesting the Scobey::DisplayTextfile() free function ... "
 15:         "\n\nThis program displays on the standard output, twice, a "
 16:         "textfile chosen by the\nuser, once 23 lines at a time (the "
 17:         "default), and once 10 lines at a time."
 18:         "\n\nWhen entering the name of a file, the full path may be "
 19:         "given if the file\nis not in the same directory as the "
 20:         "executable, but under Windows it will\nbe necessary to enter "
 21:         "two backslashes (\\\\) instead of one backslash (\\)\nto "
 22:         "separate directories on the path.");

 24:     string fileName;
 25:     cout << "Enter name of file to display: ";
 26:     cin >> fileName;  cin.ignore(80, '\n');

 28:     cout << "\n\nFirst we display the file 23 lines at a time.";
 29:     DisplayTextfile(fileName);

 31:     cout << "\nNext we display the same file 10 lines at a time.";
 32:     DisplayTextfile(fileName, 10);

 34:     Pause(0, "No more tests to perform."
 35:         "\nProgram will now terminate.");
 36: }