0

a C++ program that calculates the number of times a
given substring is found in an input string. Please, check carefully the list standard C-string functions, and decide which of them can be utilized to solve the task.
Example: consider a string “tank capacity was measured many times” to search in and a
substring “an” specified by a user – under these circumstances program outputs 2. If the input substring
contains just one character “a”, the result becomes 6.
Hypothetical dialogue may have the form given below:
Input string for search: tank capacity was measured many times
Input substring to search for: an
String “an” found 2 times
Wish to continue search (y/n)?: y
Input substring to search for: a
String “an” found 6 times
Wish to continue search (y/n)?: y

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

How much of this have you already written ? None? then why not? Do it in small steps and it will be a lot easier for you to code. Start here

int main()
{
    return 0;
}

Compile that and if it compiles add another little bit, such as display the first prompt you need. Do it in very small steps and you will soon have the whole program written.

Good luck :) Please post code and ask questions about what confuses you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.