题目内容:
请编写函数proc(),它的功能是:求出str所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412341123,输入字符4,则输出2。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若十语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define N 8l
int proc(char*str,char c)
{ }
void main()
{ char a[N],ch;
system("CLS"):
printf("\nPlease enter a strin9:");
gets(a):
printf("\nPlease enter a char:");
ch=getchar();
printf("\nThe number of the char is:%d
\n",proc(a,ch));
}
参考答案:
答案解析: