我对编程很陌生,我正在尝试在整个文件夹中查找关键字。 我收到错误0x80070002,甚至无法打开文件。希望能得到我的任何帮助。
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);
};
如何通过fstream编写相同的代码,以及如何将fstream文件转换为字符串?