Function to find Occurrences

Write a function Occurrences() in a language of your choice that takes in two strings. The first is a search string, and the second is a sentence. For example, running the function:

Running Occurrences ("o", "Red Gate Software - Ingeniously Simple Tools")

will output: Occurrences of 'o': 4

Occurrences ("at", "The cat sat on the mat")

will output: Occurrences of 'at': 3

charles.

Questions by prissicharles

Showing Answers 1 - 2 of 2 Answers

the_code

  • Aug 24th, 2011
 

Below is the code to do this in C language. Hope this helps.

Code
  1. #include<stdio.h>

  2. #include<string.h>

  3. "The fat cat sat on a mat""at""total %d occurences found

  4. "

  Was this answer useful?  Yes

shashank

  • Nov 3rd, 2011
 

Code
  1. span style="color: #ff0000;">"occurances = %d",occ("at","the cat sat on the mat"));

  2. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions