#include<iostream> #include<cctype> using namespace std; void stringupper(char*)
ID: 3610868 • Letter: #
Question
#include<iostream>
#include<cctype>
using namespace std;
void stringupper(char*);
int countchar(const char*,char)
int main()
{
char strgl[]="fdsgnsdfgsdg";
char *ptr_strgl=strgl,ch='G';
stringupper(ptr_strgl);
cout<<"The letter"<<ch<<" appears"
<<countchar(ptr_strgl,ch)<<" times in the string "
<<ptr_strgl<<endl;
return 0;
}
int countchar(const char*ptr_strg, char ch)
{
int cnt(0);
while(*ptr_strg)
{
if(*ptr_strg == ch)
cnt++;
ptr_strg++;
}
return cnt;
}