外管局网站做延期收汇报告,网站建设是什么科目,android开发工具手机版,网站建设的一般流程1、问题
函数应该在第一个参数中进行查找#xff0c;并返回匹配第二个参数所包含的字符的数目 2、代码实现
#include stdio.h
#include string.h//函数应该在第一个参数中进行查找#xff0c;并返回匹配第二个参数所包含的字符的数目
int count_chars(char…1、问题
函数应该在第一个参数中进行查找并返回匹配第二个参数所包含的字符的数目 2、代码实现
#include stdio.h
#include string.h//函数应该在第一个参数中进行查找并返回匹配第二个参数所包含的字符的数目
int count_chars(char const *str, char const *chars)
{ if (str NULL || chars NULL)return 0;int count 0;while ((str strpbrk(str, chars)) ! NULL){//如果有匹配的记得把指针右移一下str;count;}return count;}int main()
{const char *str chengongyyuhellogyy;const char *chars chenyu;printf(count_chars(%s, %s) is %d\n, str, chars, count_chars(str, chars));return 0;
} 3、运行结果
gcc -g count_chars.c -o count_chars
./count_chars
count_chars(chengongyyuhellogyy, chenyu) is 12