如何在文件中查找字符串?在我的代码中,我想在文件中找到一个人的名字。并在评论中执行操作。这是我的代码:
int main(){
size_t found;
ofstream myfile;
cout << "Enter the name you wish to delete." << endl;
getline(cin, name);
myfile.open("database.dat");
found=myfile.find(name);
if (found!=string::npos){
number = myfile.tellg();
/*Delete current line and next line*/
}
}