CS 31 Lab 7: A string library

Due 11:59pm, Tuesday November 13


Handy References

Lab 7 Goals:

Lab Description

For this lab, you will implement your own version of the core functions in C's string processing library. In C, strings are just blocks of memory (e.g., static arrays, or a dynamically allocated block of bytes) that contain one character after another and are terminated with a special null-termination marker.

These library functions abstract the details of memory and null-termination from the user to make strings less painful to use. Unfortunately, while they're much better than nothing, the functions are still quite low-level. For example, you cannot concatenate strings with a + operator like you can in many other languages, and using strcat requires that the user allocates and provides sufficient memory.

Since strings are everywhere, it's extremely likely that you'll find yourself using these functions frequently. A great way to learn how they work is to implement them yourself, so that's what we'll be doing in this lab.

You'll be implementing the following functions:

Once you've written your implementation of these functions, you'll write a small number of test cases for each to compare your version with that of the built-in C library. This should help you to convince yourself that your implementation is correct.

Requirements

Tips

Submitting

Please remove any debugging output prior to submitting.

To submit your code, simply commit your changes locally using git add and git commit. Then run git push while in your lab directory. Only one partner needs to run the final push, but make sure both partners have pulled and merged each others changes. See the section on Using a shared repo on the git help page.