WSQ 11 – Finding and counting a word in a text

This time I made a program that looks for a word in a text file and counts how many times does this word appears in the file. I found this program very similar to the last one I did for the WSQ 9 because it involved working with text documents in C++ too.

I first made the program just looking for the word banana when it was written just like that and then i realized that I need to adjust the program for looking also for banana when it is writed in a different way like BanaNa o BANaNa so I looked for information and I found the function that convert the file to lowercase and after that I made the count.

Screen Shot 2017-11-11 at 11.34.31 AM

You can find my full code here:

https://github.com/getorres99/TC1017-Fall-IMT-GTO/blob/master/WSQ11Findwords.cpp

 

The normal consult book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.

Some information about the fstream library:

http://www.cplusplus.com/reference/fstream/fstream/

Tolower function:

http://www.cplusplus.com/reference/cctype/tolower/

#WSQ11#teclife

 

 

Deja un comentario