#include //#include #include char search(char *word, char *s_word); int main(void) { char word[100] , s_word[100]; printf("문자 입력 : "); fgets(word,sizeof(word),stdin); while(1) { printf("검색할 문자열 입력 (종료는 end) : "); fgets(s_word,sizeof(s_word),stdin); s_word[strlen(s_word)-1] = '\0'; if(strcmp(s_word,"end")==0) break; search(word,s_word); } return 0; } char search(char *word, char *s_word) { char *temp, w_temp[100]; int cnt=0, s_cnt=0, size = strlen(s_word); strcpy(w_temp,word); while(2) { if(strlen(w_temp+s_cnt)==1) break; else { if(strncmp(w_temp+s_cnt,s_word,size) == 0) { cnt++; s_cnt+=size; } else { s_cnt++; } } } printf("검색결과 : %d\n",cnt); }