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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.