C/C++の宿題片付けます 153代目at TECH
C/C++の宿題片付けます 153代目 - 暇つぶし2ch149:デフォルトの名無しさん
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));
}



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch