Re: Writing a character to the beginning of the same file
- From: Randy Howard <randyhoward@xxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Apr 2005 10:40:14 GMT
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
.
- Follow-Ups:
- 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
- Writing a character to the beginning of the same file
- Prev by Date: Re: Writing a character to the beginning of the same file
- Next by Date: Re: xAml ?
- 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
|