simple text-query program. Our program will let a user search a given file for words that might occur in it. The result of a query will be the number of times the word occurs and a list of lines on which that word appears. If a word occurs more than once on the same line, we’ll display that line only once. Lines will be displayed in ascending order—that is, line 7 should be displayed before line 9, and so on.
run
./a.out phone.txt
when phone.txt is example txt source.
run the following queries:
- NOT word
- word1 AND word2
- word1 OR word2
- word1 n word2
- word
else will show:
Unrecognized search