As the title states, few things I must add to explain: " "/tab/","/"."
are things that divide words in my situation, another note that there can be more the one space or dot coming one after the other
this is what I have
int countWords(char * str, int length){
int counter = 0;
for( int i = 0; i < length; i++){
if(( str[i] == " ") || ( str[i] == ".") || ( str[i] == ",")){
if(( str[i+1] != " ") || ( str[i+1] != ".") || (str[i+1] != ",")){
if(( str[i-1] != " ") || ( str[i-1] != ".") || (str[i-1] != ","))
counter++;
}
}
}
return counter;
}
I get an error saying that I can not compare int and a pointer, I do understand where that is coming from, but how can I get it to actually work?
Note* I can't use string.h