Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to create two simple file utilities using the C language-- one to copy files and the other to display the contents of text

You are to create two simple file utilities using the C language-- one to copy files and the other to display the contents of text files:mycopyThis is the simpler of the two utilities; it simply copies a file. Following are the specifications:The usage of mycopy is as follows:

mycopy   

If the file to be copied does not exist or the user lacks permission to read it, mycopy emits an error message and quits.

If a file or directory already exists with the name proposed for the copy, mycopy emits an error and terminates.

You are to write code within the main function of the file mycopy.c, which is supplied with this assignment. You may also add your own functions, if you wish.

mypagerThis utility displays the contents of a file as ASCII characters, one "page" at at time. By default, a page is equivalent to at most 20 lines of text, each line not having more than 80 characters displayed. It is, essentially, a crude version of the less Unix file utility. Following are the specifications:The usage of mypager is as follows:

mypager  

When started, it displays the first page of text, meaning up to 20 lines of text from the file, each line having 80 characters or less.

It then waits for user input. If the user presses the 'f' key, then the next page is displayed. If the user presses the 'q' key, then the utility quits. This user input code has already been written and is included within the main function.

You will be supplied with an incomplete version of mypager.c that does not actually display any text. You are to modify several functions within mypager.c in order to make it work correctly. Specifically, you must revise three (3) functions, as follows:

fetch_next_line: this function retrieves the next line of text by repeatedly calling fetch_next_word; see mypager.c for more details

fetch_next_word: this function retrieves the next word of text by reading bytes from a buffer; see mypager.c for more details

refill_buffer: this function refills the buffer with bytes read from the file; see mypager.c for more details

You may not revise or add any other functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Define the analytical notion of metrics.

Answered: 1 week ago

Question

What is Ramayana, who is its creator, why was Ramayana written?

Answered: 1 week ago

Question

To solve by the graphical methods 2x +3y = 9 9x - 8y = 10

Answered: 1 week ago

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago