gnirtS a esreveR

This is a pair exercise and must be competed in your tutorial or lab with your partner.

For this activity, you’ll be writing the function stringReverse:

void stringReverse (char *buffer);

It takes a string in buffer, and reverses the characters in it in-place. You should always make sure that your function maintains the null-terminator at the end of the buffer array.

Download stringReverse.c, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week05/files/stringReverse.c .

An interesting quirk to be aware of: a string literal is immutable, but string created as an array is mutable.

We’ve provided a simple test to help you build your solution. You should write more tests to demonstrate your solution works.

To run some simple automated tests:

$ 1511 autotest stringReverse

To run Styl-o-matic:

$ 1511 stylomatic stringReverse.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk05_stringReverse

Or, if you are working from home, upload the relevant file(s) to the wk05_stringReverse activity on Give Online.