CS 2213 Advanced Programming, Fall 2000 Lab Assignment 4


Due Thursday, October 19, 2000

Lab Assignment 4 has only one part.


Write a function:
char *search(char *s, char *t);
which returns a pointer to the first occurrence of the string t in the string s. It returns NULL if not found. The function should not modify either string. You may not use any of the library functions.

Write a main program that uses getLine to read in two lines and output the results of the search. If not found, an appropriate message should be displayed. If found, display the string that is returned by search. The first string entered will be s and the second one will be t. When testing, you probably do not want the second string to contain a newline, so use CTRL-D to enter a string without one. You can enter the string "def" by following "def" with two CTRL-D's.

Test your programs to make sure they work.

Handing in your assignment:

As usual you will send an email to cs2213.

You email should contain the source code for search and any functions it calls as well as the output from two runs of your program, one in which the string was found and one in which it was not. It should be clear from the email what the two strings entered were. The second string should not contain a newline. Do not include anything extra in the email. The total number of lines of source code in the email should be well under 20 lines.