07/07/24 07:58:32
>>811
#include<stdio.h>
int main( void ){
char c, string[100], *pstr;
int count;
printf( "文字列を入力してください\n" );
scanf( "%s%*c", string );
printf( "さがす文字を入力してください\n" );
scanf( "%c%*c", &c );
pstr = string;
count = 0;
while ( *pstr != '\0' ) {
if ( *pstr == c ) {
count++;
}
pstr++;
}
printf( "入力された文字列の中に指定された文字は%d個あります\n", count );
return 0;
}