반응형
#include <stdio.h>
#include <string.h>
int count( const char * str , char c )
int main( int argc , char **argv ) { char * str ="aa|bb|cc|11"; int i; if( i= count( str , '|' ) ) { printf( " %d \n", i ); } return 0; } int count( const char * str , char c ) { if( str == NULL ) return -1; int i,t=0; for( i = 0; i < strlen( str ); i ++ ) { if( str[i] == c ) { t++; } } return t; }
반응형