how can i delete a whole line just by searching a single word in that line? for example: "i want to delete this line" (this is the sentence in the line) and i will only search the delete word and the rest of the word in that line will be delete?
here's my code
string deleteline;
string line;
ifstream fin;
fin.open("example.txt");
ofstream temp;
temp.open("temp.txt");
cout << "Enter word: ";
cin >> deleteline;
while (getline(fin,line))
{
if(line != deleteline)
temp << line << endl;
}
temp.close();
fin.close();
remove("example.txt");
rename("temp.txt","example.txt");