http://pastebin.com/K7RRQuuH

(댓링 예정)

위에 링크가 코드 있는 링크고 이게 코드 전문


#include <stdio.h>
#include <string.h>

int WordsCounter(char* str);

int main()
{
char str[100] = { 0 };
int wordCount = 0;

puts("======== This program is Word Counter. ========");

gets(str);

wordCount = WordsCounter(str);

printf("\n[Your string has '%d' words.]\n\n", wordCount);

return 0;

}

int WordsCounter(char* str){
char strBuff[50] = { 0 };
int wordCnt = 0;

for (int i = 0; i < sizeof(*str); i++) {
if (str[i] != '.')
strcat(strBuff, str[i]);
if (str[i] == ' ') {
printf("%s\n", strBuff);
for (int j=0;j<sizeof(strBuff);j++)
strBuff[j] = '\0';
wordCnt += 1;
}
}
return wordCnt;
}

C++인데 현재 소스파일을 .c로 쓰고있음 (비주얼 스튜디오)

오류는 없고 경고는 4개 있는데(1은 13번째 줄 나머지 오류는 다 29번째 줄)

1. 'gets'가 정의되지 않았습니다. extern은 int형을 반환하는 것으로 간주합니다

2. '함수': 'const char *'의 간접 참조 수준이 'char'과(와) 다릅니다.

3. 'strcat': 형식 및 실제 매개 변수 2의 형식이 서로 다릅니다

4. 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.