Adobo
Carbohydrates
Meal
Philippines
Very_good
9
i need to delete all 6 info in the text file. but my code can only delete one line.
char deleteline[50], a[20];
string line;
ifstream sup;
sup.open("infile.txt");
ofstream temp;
temp.open("myfile.txt");
information lists;
cout << "What INFORMATION do you want to remove? ";
cin >> deleteline;
while (getline(sup, line))
{
for (int x = 1; deleteline[x] != '\0'; x++)
{
if (line != deleteline)
{
temp << line << endl;
cout << "Information(s) was succesfully deleted." << endl;
}
else
cout << "Information(s) was not found." << endl;
}
}
temp.close();
sup.close();
remove("infile.txt");
rename("myfile.txt","infile.txt");

New Topic/Question
Reply



MultiQuote




|