Question
I have one c++ coding question, please help me complete it thank you so much my angel In the following program, implement two functions, named
I have one c++ coding question, please help me complete it thank you so much my angel
In the following program, implement two functions, named searchACharacter, to count the number of characters in a string using the following parameters: A Cstring to be searched, a character to be searched for, and the count argument to pass back the counting result.
The signature for the two overloaded functions is provided. Assume that your implementation will be inserted at TODO
#include
using namespace std;
void searchACharacter(char[], char, int&);
void searchACharacter(char[], char, int*);
int main()
{
char str[] = "A quick brown fox jumps over the lazy dog.";
char ch = 'o';
int count = 0, count1 = 0;
int* count_ptr = &count1;
searchACharacter(str, ch, count);
cout << "Number of occurances of the character \'" << ch
<< "\' in the string " << endl;
cout << "\"" << str << "\"" << endl;
cout << "is: " << count << endl;
searchACharacter(str, ch, count_ptr);
cout << "Number of occurances of the character \'" << ch
<< "\' in the string " << endl;
cout << "\"" << str << "\"" << endl;
cout << "is: " << *count_ptr << endl;
}
// TODO-1: write definition of the function searchACharacter with
// parameters char [], char, and int&
// TODO-2: write definition of the function searchACharacter with
// parameters char [], char, and int*
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started