문자열 (1) 썸네일형 리스트형 단어의 갯수를 세는 소스 #include #include #include #define SIZE 1024 int word_cnt(); int word_cnt(char *string){ int count = 0; while(*string != '\0'){ // 문장이 끝날대 while (isspace(*string)) // 포인터가 가르키는 인덱스가 공백인 경우 string++; //다음 인덱스로 포인터를 변경 if(*string != '\0'){ count++; while (!isspace(*string) && *string != '\0') string++; } } return count; } int main(){ char string[SIZE]; printf("입력하신 단어의 수를 세는 프로그램이다?"); gets(string.. 이전 1 다음