> but when i compile this it is giving me an out put of 1
> even though i enter "strange#"
> should'nt it give an output of 8 instead of 1..
It increments the counter whenever whitespace is encountered. There isn't 8 whitespaces in "strange" is there? Besides, counter=0 after exection when strange#<newline> is input.
unsigned int words=0, i=0, len=strlen(buf);
//words is number of words in buf