int wordcount(char *str,int n)
{
int i=0,count=0,count1=0;
for(i=0;i<strlen(str);i++)
{
if(str[i]!=' ' || str[i]!='\n' || str[i]!='\t')
{
count++;
}
else
{
if(count<=n)
{
count1++;
}
count=0;
}
}
if(count<=n)
return (count1+1);
else
return count1;
}
count the number of words in str with number of characters equal to or less than length. The word must have whitespace on both sides (space, tab, newline or carriage return), unless it is at the beginning or end of the string str . For example if length == 3 , the function should be able to count all occurrences of words such as {the, in, a, of, all, ...etc}
My problem is: Whenever I enter the '\n' and '\t' and '\r' in the if statement with an or condition alongside ' ' it is giving 0 as answer but if I am only using ' ' it gives me correct answer.
Can anybody explain it to me?