![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| select a portion of a file into a CSV | anju | Shell Programming and Scripting | 8 | 02-27-2008 10:50 PM |
| extract date portion from file | misenkiser | Shell Programming and Scripting | 5 | 10-06-2006 02:37 AM |
| extract a portion of log file | chandra004 | Shell Programming and Scripting | 8 | 08-03-2006 05:20 PM |
| display a portion of lines from file | champion | UNIX for Dummies Questions & Answers | 6 | 09-20-2005 08:11 AM |
| remove portion of file | methos | Shell Programming and Scripting | 13 | 08-16-2002 06:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Delete Portion of a file
hi i would like to know whether i can delete a part of a file in C
for eg. if my file contained 1234567890 and i want to delete 456 so that it becomes 1237890 is there a way i can do this. well, one way i can achieve this is by creating a new file, copy whatever i want, then delete the old file and rename the new file with the name of the old file. but i was wondering whether it can be done in directly, i.e. without doing any copies. plz help regards Edit/Delete Message |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
good question
The only method i know is the one u just wrote, but what if u can overwrite the unwanted characters by shifting the ones after them to the left, then insert the END OF FILE (EOF) in it's correct position? i don't know if it's possible, and there's the matter of space: will the file be shrinked or it'll remain the same size? because we're not "deleting" anything, we'r just changing the sequence of characters....
|
|
#3
|
||||
|
||||
|
It is possible to move characters down with a read and write loop and you can call truncate() to shorten the file.
|
||||
| Google The UNIX and Linux Forums |