Hello everyone,
I have a project which is to find the permuted index of each word in a textfile.
Im restricted from using STL btw.
I read in input.txt and have to output each word and corresponding line number and if it is found multiple times, it will have (numoftimes) it appears.
sample input:
hello there hello where
see you see me
sample output:
hello: 1(2)
there: 1
where: 1
see: 2(2)
... and so on
I want to know if what I plan to do is good or need some hints on how to do it.
First off, is there a way to find out the number of lines of a text file before reading it?
I was planning using a linked list, each node containing a string, and array[numoflines]
and each time I see the same word I update array[numoflines]++
for example if I see "hello", my node would have string as hello and aray[1] = 1
when I see it again it would be array[1] = 2 so I know it appears in line 1 twice.
Is this a good way to start or is not very efficient?