Functions and Recursions – Strings – Problem #3
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
1. Write a program that would read three character strings str1, str2, and str3 of sizes upto 20, 6, and 6 respectively. Display the three strings. Then, invoke the two functions checkStr( char *str1, char * str2) and repStr(char *str1, const char *str2, const char "str3). a. checkStr( char *str1, char *str2): Check whether str2 occurs in str1 as a substring and display the positions of all occurrences. Do not use any string library functions. [5 Marks] b. repStr(char * str1, const char *str2, const char *str3): Replace all occurrences of str2 in str1 by str3 and display the newly formed string.