Write a program that implements and tests the following functions for use with C-strings (you may assume that input obtained by the program is limited to a maximum of 80 characters):
int charcnt(char* ptr, char c);
This function, when given a C-string reference and a character, returns the number of times that the specified character occurred in the string.
int repeat(char* ptr);
This function, when given a C-string reference, returns the number of repeated characters that occur in the string. For example, the string "Mississippi" has three repeated characters. Do not count repeated blanks in the string.If a character occurs more than two times, it should still only count as one repeated character; thus, "hisssss" would have only one repeated character.
void reverse(char* ptr);
This function when given a C-string, will reverse that character string. For example, "Harry" becomes "yrraH".
Please note that you are NOT to use any prewritten C-string functions (e.g. strlen) as the purpose of this
problem is to get experience in writing such functions. You are to use cin.getline to read in the string and
cin.get to read in the character as shown below:
Example run (with user input indicated with bold italics):
Enter a string: The Mississippi Snake goes "hisssss, y'all."
Enter a character: s
The character 's' appears 10 times in the string.
There are 5 repeated characters in the string.
The reverse string is: ".lla'y ,sssssih" seog ekanS ippississiM ehT
Test Run #1:
Enter a string: Mr. Boone is a bookkeeper in Mississippi.
Enter a character: s
The character 's' appears 5 times in the string.
There are 7 repeated characters in the string.
The reversed string is: .ippississiM ni repeekkoob a si enooB .rM
Test Run #2:
Enter a string: The quick brown fox jumps over the lazy dog.
Enter a character: e
The character 'e' appears 3 times in the string.
There are 0 repeated characters in the string.
The reversed string is: .god yzal eht revo spmuj xof nworb kciuq ehT