https://www.youtube.com/watch?v=s3-DmI1ZWxE
c++ pek uzağım hocam ama burda adam deneyip testini yapmış. yardımcı olabilir (konsoldan girdi istiyor. onun yerine fonksiyona çevirip bitirirsiniz)
kodlar böyle bişeymiş (düzenlersiniz)
#include <iostream>;
#include <fstream>;
#include <string>;
using namespace std;
int main(void) {
string search;
int offset;
string line;
ifstream Myfile;
Myfile.open("names.txt");
cout << "Type the name you want to search" << endl;
cin >> search;
if (Myfile.is_open())
{
while (!Myfile.eof())
{
getline(Myfile, line);
if ((offset = line.find(search, 0))) != string::npos)
{
cout << "The word has been founded " << search << endl;
}
}
Myfile.close();
}
else
{
cout << "Could not open file" << endl;
system("PAUSE");
return 0;
}
}