This code is made to count words. But instead of displaying numbers of words, it prints 0.Code:#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char words[200]; int d,i,k=0; while(scanf("%s",words)==1){ k=strlen(words); d=0; for(i=0; i<k; i++) { if(words[i]=='\0') { d++; } } printf("%d",d); } return 0; }
=_=
eg;
input : hi my name is bob!
instead of
output: 4(Words)
it outputs 0000
Much help needed. Extremely newbie programmer.