Searching through an entire folder for a keyword

-1

I'm quite new to programming and I'm trying to find a keyword in an entire folder. I get an error 0x80070002 and can't even open the file. Hoping to get any help i can.


class WordFromFolder {
private:
    string path;

public:
//function to find a character in a file
     int findChar(string file, string c) {
        int counter = 0;
        cout << "Enter a word" << endl;
        cin >> c;
        if (file.find(c))
            counter++;
    }
    //entering the folder 
     int enterFolder(string path)
    {
        vector<string> numberofFiles;
        unsigned int number_of_files_in_directory(_FILESYSTEM_::basic_string<string>path);
        {

            for (auto& file : path)
            {
                numberofFiles.size++;
            }
            return numberofFiles.size();
        }
        while (numberofFiles.size() > 0)
        {
            findChar(path, "word");
        }
    }

//the main file looks like this
WordFromFolder file;
    string filepath = "C:\\Users\\PC\\source\\repos\\WordFromFolder\\WordFromFolder\\ROME.docx";

    string getaWord ="word";

    file.enterFolder(filepath);

};

How could I write the same code via the fstream and how do i convert an fstream file into a string?

c++
arrays
file
iterator
char
asked on Stack Overflow Dec 21, 2019 by abc123

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0