#WSQ12-Word count

Este programa me gusto, aunque no funciona como debería capilla pero no muestra ninguna resultado aun así dejo el código:

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int find_word(string word, string tipo){
string line;
int cont=0;
ifstream myfile(tipo);
if (myfile.is_open()){

while ( getline (myfile,line) ){
if(‘line’ == ‘word’){
// cout << line << endl;
else {
cout<<“CANNOT OPEN THE FILE”<<endl;
cout<<“The word…”<<word<<“… is used “<<cont<<” times.”<<endl;
return cont;

int main(int argc, char const *argv[]) {
string word, tipo;
int cont;
std::cout << “Please type the word you want to search.” << std::endl;
std::cin >> word;
std::cout << “Please enter the name of the file to search the word” << std::endl;
std::cin >> tipo;
find_word(word, tipo);
return 0;

Captura de pantalla 2016-05-14 a las 10.48.52.png

CC BY-SA 4.0 #WSQ12-Word count by lilihecblog is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.