Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 Introduction The more command in UNIX can be used to view a file one page at a

ID: 3611324 • Letter: 1

Question

1 Introduction
The more command in UNIX can be used to view a file one page at atime. While executing more,
press the space bar to display the next screen of text. A carriagereturn will advance the screen
forward one line at a time. The format is:
more file

2 Problem
You are to implement your own more command. Your command need nottake a command-line
argument, instead you can prompt the user for the name of the filethey would like to view. Your
program should understand the following commands and execute theassociated actions:
q { quit more
space bar { read next page
return key { read next line
Basically, your program will act as a page turner" for viewinglarge files. Feel free to pick a
reasonable page" size (perhaps 20 lines or so) that constitutesthe number of lines of a page. Store
this data a constant and reference it throughout your program. Thatway, it would be easy to
change the page in a single location.

/*
* Prompts the user (via stdout) for a file name, checks whetherthat file can
* open properly, and connects that file tofile_input_stream.
*/
void fill_in_input_file(ifstream&file_input_stream);

/*
* An enumerated type representing the different actions a usercan take.
*/
enum Response {SHOW_PAGE, SHOW_LINE, QUIT};

/*
* Prompts the user for an action and returns the associated'Response' from * the user.
*/
Response show_prompt();

/*
* Outputs (to stdout) a single line from file_stream. Iffile_stream is
* currently at 'end of file,' then this function has noeffect. */
void display_line_from_file(ifstream&file_stream);

/*
* Outputs (to stdout) a single page from file_stream. Iffile_stream is
* currently at 'end of file,' then this function has noeffect.
*/
void display_page_from_file(ifstream&file_stream);

Explanation / Answer

please rate - thanks now it's standard, but you must enter space enter, or q enter forthe commands #include #include using namespace std; enum Response {SHOW_PAGE, SHOW_LINE, QUIT}; void fill_in_input_file(ifstream& file_input_stream); Response show_prompt(); void display_page_from_file(ifstream& file_stream); void display_line_from_file(ifstream& file_stream); #define LINES 24 int main() { Response choice; ifstream in; fill_in_input_file(in); choice=show_prompt(); while(choice!=QUIT)    {if(choice==SHOW_PAGE)       display_page_from_file( in) ;     else        display_line_from_file(in);     cout