0

Can anyon help me with the code to delete from file using the delete method or function

void delete()
{
}

Thanks in advance

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by unbeatable0
0

If its a text file then you have no other choice but to rewrite the entire file. Open original file for read, open another temp file for write. In a loop read a line from input file and if its not the line you want to delete just rewrite it to the putput file. If it is the line you want to delete just ignore it and read the next line. Do that until end-of-file. Close both files. Delete the original file. Rename the temp file to the name of the original file.

0

If its a text file then you have no other choice but to rewrite the entire file. Open original file for read, open another temp file for write. In a loop read a line from input file and if its not the line you want to delete just rewrite it to the putput file. If it is the line you want to delete just ignore it and read the next line. Do that until end-of-file. Close both files. Delete the original file. Rename the temp file to the name of the original file.

I dont know what would I do without u, thanx man but can u provide me with a sample code so I can just replace

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.