Quote:
How do I count specific words in a text file
Hi Jarvis/Samuel you have already posted essentially the same question with another account, it tend to upset helpers here.
How do I count lines, words and keywords in a text file[
^]
Your main change is removing the general words counting as it was wrong.
Hint:
Your problem is that you can't count words just with 1 char at the time.
You need to remember what was the previous char.
You have a new word when last read char is part of a word and previous char is not part of a word.
You also need to define which char is part of a word.
To count specific words:
you first need a list of those words.
then you need a way to detect beginning of general words, which is essentially the previous task.
then you need a pointer to know where you are in the list of specific words.
Advice: start by detecting a single specific word, then elaborate.
Advice: reading a full line in a buffer may simplify the code.