ファイル内の文字列を見つけるにはどうすればよいですか? 私のコードでは、ファイル内の人の名前を見つけたいと思っています。コメントでアクションを実行します。これが私のコードです:
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*/
}
}