============================================================================ Faculty of Applied Science and Engineering, University of Toronto CSC181: Introduction to Computer Programming, Fall 2000 Practical Notes, Week 9: String Processing ============================================================================ The purpose of this practical is to have you work with string processing. You will not be graded for this practical. ---------- Your Tasks ---------- 1. Write a function substringBetweenChars, which has the following prototype: char* substringBetweenChars (char* s, const char* ct, char a, char b) Given a string ct, this function copies into s the substring in ct whose first character is the leftmost occurrence of a in ct and whose last character is the rightmost occurrence of b in ct. It also returns a pointer to s. Example calls: substringBetweenChars(s, "hello", 'h', 'o') -> "hello" substringBetweenChars(s, "hello", 'e', 'l') -> "ell" substringBetweenChars(s, "hello", 'h', 'a') -> "" substringBetweenChars(s, "hello", 'a', 'o') -> "" substringBetweenChars(s, "hello", 'i', 'j') -> "" 2. Write a function endsWith, which has the following prototype: int endsWith(const char* cs, const char* ct) Given a string cs, this function returns true (non-zero) if cs ends with ct, false (zero) otherwise. Example calls: endsWith("hello", "lo") -> true endsWith("hello", "he") -> false