I have this exercise: the program receives as an input a .txt file where in the first line there is number of entries, the second line has the minimum number of times a word has to be repeated to be considered and the following lines have all the words. I have to count how many times a word is repeated and then print the word(s).
e.g.
input:
6
2
hey
tomorrow
hey
what
then
then
output:
hey
then
I worked like this: I put the input strings in vector<string> wordList, then in the seek function I count how many times a word is repeated in the vector and insert in the "counting" vector the word and how many times it is repeated. With the sort I sort them so that the number of times is in descending order and in the final loop I print out i < times words.
Result: segmentation fault. I've put some flags around and it seems that the last for loop don't work, as the program runs fine until there.