next_inactive up previous


CSE243 programming project 3
String table

Jeffrey A. Meunier, M.S. C.S.
Department of Computer Science and Engineering
University of Connecticut
jeffm@engr.uconn.edu

Due date

This project is due Monday, April 8, 2002.

Introduction

For this project you will create a string table. This table will contain a variable number of strings, much like a linked list. Each entry in the string table will contain three bytes plus the string itself. The first byte will indicate if the string is being used or if the string has been deleted (a simple 0/1 value will be sufficient; this is explained more below). The second byte will be the length of the string. The third byte will be number of bytes before the next string; initially, this will be the same as the length of the string (also explained below).

The program operates by having the user enter single-letter commands. The program performs different operations on the string table depending on the command entered by the user. The commands are:

In your programs, allocate a block of memory for the string table. One kilobyte should be more than enough for the purpose of testing this program.

Part 1: Insert string

After entering the letter ``i'' (followed by a carriage return), the user enters a string to enter into the table. The program then places the three information bytes into the table, followed by the string itself.

Part 2: Show all strings

When the user enters the command letter ``s'', display each string in the string table in order, one string per line. Be sure not to display any string which has an ``in use'' value of 0.

Part 3: Lookup string

When the user enters the command letter ``l'', read a string from the keyboard. Find the first string in the string table that begins with the string just read, and display the string.

Part 4: Delete string

When the user enters the command letter ``d'', read a string from the keyboard. Find the first string in the string table that begins with, or is the same as, the string just read, and then delete the string. To delete the string, all that must be done is to set the first byte in the string's entry to 0 (the ``in-use'' flag), and set the length of the string to 0.

Part 5: Insert string, again

Modify the string insert code so that if a string is inserted and a string of equal or greater length has been deleted, that empty space in the string table is reused for the new string. To insert this string, set the string's first byte to 1, indicating that this entry in the table is being used again, and set the string's length to the length of the string. The number of bytes before the next string does not change, since it must always indicate the location of the string following this one.

Example run

command: i
string: program

command: i
string: computer

command: i
string: memory

command: s
program
computer
memory

command: d
string: com

command: s
program
memory

command: i
string: CPU

command: s
program
CPU
memory

command: q

About this document ...

CSE243 programming project 3
String table

This document was generated using the LaTeX2HTML translator Version 2K.1beta (1.47)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -split 1 stringTable.tex

The translation was initiated by Jeffrey A. Meunier on 2002-03-27


next_inactive up previous
Jeffrey A. Meunier 2002-03-27