Advising

As part of your lab grade for week 7 (next week), all CPE, CSC, and SE majors are required to fill out a Spring Advising Form. As part of the requirements on this form, you will need to meet with your faculty adviser, so plan ahead.

Those that are not CPE, CSC, or SE majors need not submit the form, but are equally encouraged to meet with their respective adviser regarding Spring planning and registration.


This lab presents exercises on strings. You will develop a program that reads character input, processes the input, and prints a transformed string back to the user. You will write this same program in two forms. You will then develop a program that determines if one string appears within another.

You can get support files by downloading lab6.zip.


Programs

Develop the following programs in the files specified for each part. To compile your program, in the respective directory, type make debug for the debug version and make run for the run version.

Test Cases

As always, you must develop test cases for the functions that you write. It is recommended that you develop these test cases before you write the code for each function. Place the test cases in the test_cases function. You are writing two separate programs. Each program must contain a test_cases function.

Program 1 -- rot-13 by characer

Develop and test a function that takes a character and returns the rot-13 (see below) encoding of the character.

Develop a program in a file named rot_13_char.c that reads user input character-by-character using getchar until EOF (signaled by <ctrl>-D under Unix) and prints the rot-13 encoded characters to the screen.

Program 2 -- rot-13 by "line"

Develop and test a function that takes a string and converts it into a rot-13 (see below) encoding.

Develop a program in a file named rot_13_line.c that reads user input (approximately) line-by-line using fgets until EOF (signaled by <ctrl>-D under Unix) and prints the rot-13 encoded strings to the screen.

This program is very similar to the first. The real difference is the manner in which the data is read.

Program 3 -- substring

Moved to Lab #7. This part is no longer required for the Lab #6 Demonstration.


Rot-13

rot-13 (rotate by 13 places) is a simple Caesar-cypher encryption that replaces each character of the English alphabet with the character 13 places forward or backward along the alphabet (e.g, `a' becomes `n', `b' becomes `o', `N' becomes `A', etc.). This only works on the characters in the alphabet. All other characters are left unchanged. Moreover, the rotation is only within the characters of the same case (i.e., a lowercase letter always rotates to a lower case letter and the same for uppercase letters). An encoded character can be decoded by applying the rotation a second time. More information, for those curious, can be found at the Wikipedia entry for rot13.


Demonstration

Demonstrate your work to your instructor to have this lab recorded as completed.