11/11/10 14:44:24.11
>>147
前スレくらいにやったな
#include <stdio.h>
#include <string.h>
int str_chnum(const char *st,int ch){
int index=0, count=0;char *p = 0;
do{p = strchr(&st[index],ch);}while
(p&&(count++,index=p-st+1));return count;}
int main(void){char buf1[100];int buf2;
printf("文字列を入力してください:");fgets(buf1,100,stdin);putchar('\n');
printf("検索する文字を入力してください");buf2 = getc(stdin);putchar('\n');
printf("その文字は%d個含まれています。\n",str_chnum(buf1,buf2));
}