c=getchar()!= EOF
is wrong. This will first call function getchar()
. Then it will compare the return value with EOF
. After that, the result of the comparison, which will be 1 or 0, will be assigned to c
.
To avoid this, use (c=getchar()) != EOF
instad.
Instead of the second if statement, use if(isspace(c))
(Thanks to Lundin for pointing it out)
You should also specify that main should return an int to avoid warnings.