Assignments, Sep 8-9:
Assignment P2:
Use the program submit_cps149s.2 P2 name to send me the file called name which should contain your C source program, for a program which solves the following problem:
Write a C function int length(char *s) which computes and returns the length of the C string passed as its argument. You should include in the same file a main program, which should call length several times, passing it different strings each time, and printing the strings, and the value your “length()” returns for each, one such result per line.
Assignment P3:
Write a function int index(char *s, char *p) which returns i, where s[i]..s[i+length(p)] matches string p exactly, and where i is the smallest value for which this is true. If no such match can be found, return –1. Submit it as P3, as in Assignment P2, and include a main program which tests it.