Page 1 of 1

Counting individual occurrences in a file

Posted: Wed Jul 03, 2019 12:07 pm
by JurassicC
Example Output file (output.txt)

4-0-4
4-0-4
4-0-4
4-0-5
4-1-18
4-1-18
4-1-18
4-1-18
4-1-18
.
.
.
.







What I'm doing

I'm opening a file which has been created in another executable, output.txt, and putting each line in array words[] to store the words.
I'm also opening another array count[] to count all the words in the file

now this is where I am stuck.

ultimately I want to get to the point where I can output a tally of all occurrences.

word qty
4-0-4 3
4-0-5 1
4-1-18 5

etc etc

any pointer would be great :)

Re: Counting individual occurrences in a file

Posted: Wed Jul 03, 2019 1:53 pm
by SamuraiCrow
To save lookup time use the words as the keys of the count table and ditch the arrays.