e previous recitationshw first you need to get some already

e previous recitations/hw, first you need to get some already implemented programs
from the textbook. Specifically, get all the files under 09-Efficiency-and-ADTs from the class
web page. You can get all by simply following the link “programs from the textbook” and then
go to 00-zip-files and get 09-Efficiency-and-ADTs.zip and unzip it under directory X. I assume
that you already got the booklib and installed it under directory X, as we described in previous
recitations (if not, please follows the instructions at the end of this recitation to get booklib and
09-Efficiency-and-ADTs and save them under directory X)
Then go to 09-Efficiency-and-ADTs, and simply say make to compile editor.c program with
different implementation of buffer ADT. Then run editor program.
After compiling/testing existing client/diver program called array-editor, stack-editor, and
list-editor that uses different implementations of buffer ADT, you need to implement the
following functions under single linked list in listbuf.c (you can try to implement them under
other representations (i.e., array and stack) later at your own time).
void ReplaceCharInBuffer(bufferADT buffer, char oldch, char newch);
When this function is called, it should start searching from the current cursor position,
looking for the next occurrence of the character oldch in the rest of the buffer.
If it finds it, simply replace oldch with newch. Search should leave the cursor
after the last character replaced in the buffer.
If oldch does not occur between the cursor and the end of the buffer, then there
is nothing to replace and thus search should leave the cursor unchanged (in the
original place)
int SearchStrBuffer(bufferADT buffer, char* str);
When this function is called, it should start searching from the current cursor position,
looking for the next occurrence of the string str in the rest of the buffer.
If it finds it, search should leave the cursor after the found string and return the
value TRUE or 1
If the string str does not occur between the cursor and the end of the buffer,
then search should leave the cursor unchanged and return FALSE or 0
First, you need to add the above prototypes into buffer.h.
Second, you need to implement them in listbuf.c
Third, you need to update editor.c so that you can call those functions. So include the
following in editor.c:
o If user enters: Rxy, your editor.c should call ReplaceCharInBuffer (buffer, \'x\', \'y\') to
replace all the occurrences of character \'x\' with character \'y\' after the cursor.
o If user enters: Sxyz, your editor.c should call SearchStrBuffer (buffer, \"xyz\") to search
string \"xyz\" in the buffer after the cursor.

Solution

Before going on to discuss the five steps of creating a program it is important to determine what exactly a program is. A program is a list of instructions that contain data for a computer to follow. Different programs are written with different languages. An editing program is made with a different programming \"language\" than one that uses graphics. Some well known programming languages are COBOL -business, BASIC -language, and - C which is used in science. Programming is complicated process,

e previous recitations/hw, first you need to get some already implemented programs from the textbook. Specifically, get all the files under 09-Efficiency-and-AD

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site