How can we replace with same length of line. After reading one line , decided to replace it with same length, But this time file pointer is on the next line . How can I move file pointer one line back Thanks, Manoj
--- On Tue, 8/5/08, Paul Herring <[EMAIL PROTECTED]> wrote: From: Paul Herring <[EMAIL PROTECTED]> Subject: Re: [c-prog] Reading and writing same file To: [email protected] Date: Tuesday, August 5, 2008, 7:58 PM On Tue, Aug 5, 2008 at 3:06 PM, mano M <[EMAIL PROTECTED] com> wrote: > I basically need to change in the same file.Is it possibile without writing > complete output to another file. Generally no, unless the file happens to be record based. Take a plain-text file for example, separated by linefeeds. You can in-place replace a line with another line of the same length, but replacing it with a shorter line leaves old data there (would this matter?) And you cannot replace a line with a longer line without trashing the next line. If it's record based (for a text file example you'd have a table of offsets at the start of the file) you'd simply put the new data at the end of the file and update the record for that line to point to the new data. If you want a more tailored answer you're going to have to describe the file you're messing with, what's it for, what format is it, why are you changing it etc. -- PJH 'Two Dead in Baghdad' not 'product-friendly' - Kent Ertugrul, chief executive of Phorm. http://shabbleland. myminicity. com [Non-text portions of this message have been removed]
