Question: C++ Help. Write the function that counts the number of occurrence of a specific decimal digit in a string For example: int countDigit(int, string )

C++ Help.

Write the function that counts the number of occurrence of a specific decimal digit in a string

For example:

int countDigit(int, string ) ; // Function prototype

int main()

string str = "12314561asd vd&*1";

int digit = 1;

int cnt = countDigit(1, str);

// Expected output : Number of 1 in the string is 4

cout << "Count of digit " << digit << " in the string is " << cnt;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!