Re: Writing a character to the beginning of the same file
- From: "SAM" <mshyamrao@xxxxxxxxx>
- Date: 28 Apr 2005 03:51:35 -0700
Randy Howard wrote:
> In article <1114660481.571702.267690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> mshyamrao@xxxxxxxxx says...
> > So what is the solution to write a character to the beginning of
the
> > file and not affect the existing content.
>
> Homework notwithstanding consider the following:
>
>
> If it sufficiently small to store in memory
> open the file
> read the whole file into dynamic storage
> close the file
> else
> copy the file (or rename it) somewhere else
>
> open the file for writing positioned at the beginning of the file
> write the single new character
>
> Depending on the conditional above
>
> either write the contents straight from dynamic storage into the
> file just like the last character
> or
> read from the copy/renamed version of the original file and
> write into the new one
>
> close the file
> exit
>
> If that doesn't get you anywhere, drop the class or hire a tutor.
>
> --
> Randy Howard (2reply remove FOOBAR)
> "Making it hard to do stupid things often makes it hard
> to do smart ones too." -- Andrew Koenig
Randy thanks very much. I thought someone would give me a better
solution than this. I had worked on ur solution but it had taken lots
of time to complete the process in the case of large files.
Any way thankx very much.
SAM
.
- Follow-Ups:
- Re: Writing a character to the beginning of the same file
- From: Michael Wojcik
- Re: Writing a character to the beginning of the same file
- From: Bob Smith
- Re: Writing a character to the beginning of the same file
- From: Duane Bozarth
- Re: Writing a character to the beginning of the same file
- From: Randy Howard
- Re: Writing a character to the beginning of the same file
- References:
- Writing a character to the beginning of the same file
- From: SAM
- Re: Writing a character to the beginning of the same file
- From: Scott McPhillips [MVP]
- Re: Writing a character to the beginning of the same file
- From: SAM
- Re: Writing a character to the beginning of the same file
- From: Randy Howard
- Writing a character to the beginning of the same file
- Prev by Date: Re: xAml ?
- Next by Date: Which language should I learn?
- Previous by thread: Re: Writing a character to the beginning of the same file
- Next by thread: Re: Writing a character to the beginning of the same file
- Index(es):
Relevant Pages
|