+ 1

How to delete from a file?

Sololearn has told us how to read and write to a file in file handling but how to delete something from a file is not known.

2nd Jul 2019, 5:54 PM
Akash
Akash - avatar
6 Respuestas
+ 1
Hi. How about reading the file you want to remove parts from, remove the parts, and write the remaining content to file. It appears you have learned all necessary steps to carry out the operation. Hope that helps. Cheers. C.
2nd Jul 2019, 6:13 PM
ChrA
ChrA - avatar
+ 1
Thanks for suggestion ~ swim ~ , In fact I am using the same method but was looking for something shorter.
2nd Jul 2019, 6:20 PM
Akash
Akash - avatar
0
Thanks for the suggestion ChrA, I am using the same method for now but it requires me to open the file 2 times, 2nd time to open with 'w' to truncate the entire file. I was looking for some kind of Short cut.
2nd Jul 2019, 6:18 PM
Akash
Akash - avatar