Editing a file

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 21
Reputation: lexusdominus is an unknown quantity at this point 
Solved Threads: 2
lexusdominus lexusdominus is offline Offline
Newbie Poster

Editing a file

 
0
  #1
Jun 19th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 794
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 135
siddhant3s's Avatar
siddhant3s siddhant3s is offline Offline
Master Poster

Re: Editing a file

 
0
  #2
Jun 19th, 2009
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.
Siddhant Sanyam
(Not posting much)
My Blog: Yatantrika
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC