问答题

请编写函数fun,它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串:123412312,输入字符为1,则输出:3。
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
文件PROG1.C内容如下:
#include<stdio.h>
#include<string.h>
#define M 81
int fun(char *ss,char c)

void main( )
char a[M],ch;
printf("\nPlease enter a string: ");gets(a);
printf("\nPlease enter a char: ");ch=getchar( );
printf("\nThe number of the char is: %d\n",fun(a,ch));

【参考答案】

int fun(char *ss,char c){
int i,cnt=0:
for(i=0;ss[......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)
相关试题