EE 312 Project 5 - String ADT

You must complete this assignment by yourself. You cannot work with anyone else in the class or with someone outside the class. You are encouraged to get help from the instructional staff.

Due: Friday, October 6, at 11 pm

Description: The purpose of this assignment is to
1. Develop a String ADT in C
2. Practice using dynamically allocated memory and structs
3. Practice with arrays and pointers in C

In this project, you will provide a new and improved String type for C. In C, strings are just an array of ASCII-encoded characters with a zero on the end. This has some significant disadvantages. Strings are a common source of buffer overflow errors in programs. In order to determine how long a string is, each character from the beginning of a string until the null termination character must be counted. You will provide an improved version of the string in this assignment.

You will use a struct to represent a string. This struct will contain a dynamically allocated array for the string, as well as the length of the string and the size of the array. The struct for your String type is defined in the provided String.h header file, along with the prototypes for the String functions you must implement. You must use this String struct without modification. Its fields are:


The functions that you will implement are the following.


You may need to write additional helper functions to eliminate redundancy in your code. The provided tests in Proj5Test.c are weak - you will need to write your own tests to ensure that your code is working correctly.

Write a makefile that builds the executable project5. You will submit a zip file a5.zip with no internal directory structure. Zip together these files: makefile, String.c, String.h

Provided files: String.h, Proj5Test.c

You will implement the functions that are declared in String.h in the file String.c. Place the standard EE 312 project header at the top of your String.c file, as well as these:
#include "String.h"
#include<stdio.h>
#include<stdlib.h>

You may not add other #includes to this file. You may not use any string manipulation functions from stdlib.h. You may not define other structs or define any globals. Do not add anything to this file other than documentation and the implementation of the functions from the provided String.h and any helper functions that you may need.

In the standard EE 312 project header, you must replace <NAME> with your own name and you must modify the project description to describe this project. Include a detailed comment right before each function summarizing what it does, as you always should. Provide comments for any significantly complex chunks of code in your functions.

All of your projects are graded on their design as well as correctness.

Notes:
1. We will not test your code with null pointer arguments.
2. You may not use any functions (e.g., strlen, strcat) from string.h.
3. Write your own tests. The provided tests are not sufficient.
4. Use valgrind to check for memory leaks. We will use valgrind when we test your program.
5. Do not modify String.h. You must use the provided struct and function prototypes.

Checklist: Did you remember to


Many thanks to Dr. Craig Chase and Dr. Vallath Nandakumar for the idea for this project.