| | |
Editing a file
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 2
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
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
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.
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
(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
![]() |
Similar Threads
- Editing a file problem (Python)
- editing file (Java)
- EDITING file (C++)
- Edit sendmain aliases file. (Perl)
- Text File Editing Help Required. (Windows NT / 2000 / XP)
- How to populate an array? from a FILE (C)
- Error trying to write to existing file (C)
- C++ Error : opening file a second time for a read (C++)
Other Threads in the C++ Forum
- Previous Thread: Draw shapes in C++
- Next Thread: Trouble writing code for arithmetic calculations of complex numbers
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings studio temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





