问答题

请编写函数proc(),它的功能是:求出str所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串12341234123,输入字符4,则输出2。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define N 81
int proc(char * str, char c)


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

【参考答案】

int proc(char*str, char c)
{
int i=0; //i是放与c相同的字......

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