我一直试图想出一个代码来删除保存在文本文件中的数据,但无济于事。应该怎么做??在 C++ 中,这是我的代码,我该如何改进它,以便删除保存的数据可能是逐个条目的?
#include<iostream>
#include<string>
#include<fstream>
#include<limits>
#include<conio.h>
using namespace std;
int main()
{
ofstream wysla;
wysla.open("wysla.txt", ios::app);
int kaput;
string s1,s2;
cout<<"Please select from the List below"<<endl;
cout<<"1.New entry"<<endl;
cout<<"2.View Previous Entries"<<endl;
cout<<"3.Delete an entry"<<endl;
cin>>kaput;
switch (kaput)
{
case 1:
cout<<"Dear diary,"<<endl;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin,s1);
wysla<<s1;
wysla.close();
break;
}
return 0;
}