Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An implementation of the program tee.c is available at / student / cmpt 2 1 4 / 2 0 2 4 / summer / starter

An implementation of the program tee.c is available at
/student/cmpt214/2024/summer/starter/le4/tee.c. This program resembles the pro-
gram tee that you have used in Lab exercise 2, except that this program has a particular
liking to the letters c,m,p, and t. The program likes to capitalize those letters when-
ever it finds them. Do not change this. Moreover, there is a number of logical and syntactic
errors in this program (using the appropriate compiler options in your Makefile will reveal
some of the syntactic errors). Your task is to find and fix all errors. There are 4 errors in
total. Some errors will be easy to fix (gcc will point you to the errors), and some will require
you to read the comments in the code, consult the man pages regarding the C functions you
are not familiar with, and use gdb.
Do not get overwhelmed by the code. The errors are all related to things you have already
used and have been discussed in class. The man pages might talk about things you dont
understand yet. Ignore those parts. Just make sure that the logic of the program is consistent
with what it is trying to do (according to the comments and your knowledge of the real tee).
Once all errors are fixed, make sure to properly test the program. The following tests must
pass:
1. echo all of stdin back onto stdout after EOF (ctrl + D) is encountered on stdin,
2. echo all of stdin to zero or more files given as command-line arguments,
3. work correctly for inputs greater than 128 characters (do not change the values of
MIN ALLOC SIZE and MIN READ SIZE), and
4. capitalize the letters c,m,p, and t.
2
eet (reverse tee)[40 points]
Now that we have working tee program (that is a little peculiar around the letters c,m,
p, and t), we will now create another program called eet. You can start by copying tee.c
to eet.c and updating your Makefile.
The program eet works much like tee, but instead the output it gives is reversed (both on
stdout and the files specified via the command-line arguments). Your task is to analyze
the logic and structure of the original tee.c program, and find the easiest way to have it
produce reversed output (the solution is much simpler than you think). Do not worry if the
reversed output starts with an empty line. This is normal (it is the final new-line character
that went into stdin).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions