Write afunction that receives a pointer to a character string and a character .
ID: 3611231 • Letter: W
Question
Write afunction that receives apointer to acharacterstring and acharacter. Thefunction should return the number oftimes that thecharacteroccurred in the string.this is what i have... nad the teacher makred this right...but the actual problem is the next one.
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
int i,count(0),n;
char strg1[50],strg2[2];
char *ptr1(strg1), *ptr2(strg2);
cout << "Please input the string" <<endl;
cin >> strg1;
cout << "Please input the character"<< endl;
cin>> strg2;
while ((ptr1=strstr(ptr1,ptr2)) != NULL)
{
count++;
ptr1++;
}
cout << "Count: " << count <<endl;
system ("pause");
return 0;
From here.... how do i change it so that it shows only onerepreated character?
For example, is the entered "hissss"
this would have only one repreated character?