Counting individual occurrences in a file
Posted: Wed Jul 03, 2019 12:07 pm
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
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