#include <stdio.h>
int main () {
char arr[500];
int cnt = 0;
int i = 0;
printf("give your sentence : ");
scanf("%[^\n]", arr);
while (arr[i]!='\0') {
if (arr[i]==' ')
cnt++;
i++;
}
printf("words : %d\n", cnt+1);
}
'Programming > C' 카테고리의 다른 글
| VSCode mac C++ 디버깅 (0) | 2019.08.19 |
|---|---|
| scanf %s로 공백까지 입력받는 방법 (0) | 2014.11.03 |
| Selection Sort (0) | 2014.10.23 |
| 동적할당 (Dynamic allocation) (0) | 2014.09.25 |
| 메모리 구조 (0) | 2014.09.25 |