Re: Writing a character to the beginning of the same file




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

.



Relevant Pages

  • Re: Writing a character to the beginning of the same file
    ... If you have a *nix system, look up the cat command and use it at the command ... >> write the single new character ... >> either write the contents straight from dynamic storage into the ... >> Randy Howard ...
    (comp.programming)
  • Re: Writing a character to the beginning of the same file
    ... > So what is the solution to write a character to the beginning of the ... Homework notwithstanding consider the following: ... either write the contents straight from dynamic storage into the ... read from the copy/renamed version of the original file and ...
    (comp.programming)