0

Id like to edit a file. At first i thought this was going to be easy, but now it appears quite complex. As i understand it there is no standard way to delete part of a file?

im storing data on different lines in the file, and want to target a specific line to delete or edit. Ive read a bit about ios::ate, but dont know if this is the right direction, or if i should be copying the file, rebuilding it and inserting the data i want to at the right point.

Has anyone got any advice? thanks :)

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by siddhant3s
0

You are correct in saying that you cannot actually delete a part of file.
So here is what you usually do.
Suppose you want to delete everything from the 57th byte to 64th byte:
--You first copy the first 56th bytes to a temp file
--Then you copy the 65th to last byte to the same temp file.
--You delete the main file
--You rename the temp file to the same name as main file.

This question has already been answered. 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.