[Pointers and C-String]D. Liang 7.9 Occurrences of a specified character
Description:
Write a function that finds the number of occurences of a speified character in the string using the following header:
int count(const char * const str, char ch)
Hint:
Don’t submit the main() function.
Programme:
//Date:2020/5/18
//Author:Kamenrider Justice
int count(const char * const str, char ch)
{
int count=0,i,length;
length=strlen(str);
for(i=0;i<length;i++)
{
if(str[i]==ch)
{
count++;
}
}
return count;
}
8小时Python零基础轻松入门