I need to delete a string in a textfile, opening the textfile is okay
but is there a way of deleting a particular string in the textfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
string line;
int length = 0;
ifstream myfile ("Text.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
cout << line << endl;
//length += line.length();
myfile.close();
}
}
return 0;
}
|
Thanks
Last edited on
read the file in, change it, and overwrite the file with the new data
And how would you overwrite the file with the new data.....thanks