c program to count number of words in a string

Given is the c program to count number of words in a string

#include<stdio.h>

int main(void)

{

int c;

c = 0;

while(getchar()!=EOF)

++c;

printf(“%1d\n”,c);

return 0;

}