Functions and Recursions – Strings – Problem #3

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: medium

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.

Back to Lab Problems
Functions and Recursions/Strings/Problem #3

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #3

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.