Re: offtopic :)

From: Jourge Fuzz Bush (modem-burn@GEOCITIES.COM)
Date: 10/03/98

We can always say this is about circle because maybe you wanted to make
a new patch program for windows 95 that actually
Anyways you don't have to read the entire file in at once. This would be
kinda choppy but what you would do is have a char * varible and read 1
line compair the one line with the one you want to change if it is the
same then it will do something like fromfilestringvar = thenewstring;
then a fwrite or if you used ifstream *var* it would be
*var* >> fromfilestringvar
and the checker would be in a loop until eof or until a match.
That's how I would do it.
so it would look something like this (borland c++ prbly works in other
c++s. if not substitute ifstream commands with the propped fopen fread
fwrite functions and arguements)
int loop, linepos;
char *fromfile, *matchline = "testing", char *newline = "testing again";
/* other line var can be read
from another file as well*/
ifstream docfile "path\file"
/*note that I'm rember these commands from the top of my head which I
used about 2 years ago*/

do {
docfile >> fromfile
if (fromfile == matchline)
loop = 1;
close (docfile);
fromfile = newline;
ofstream file "path\file";
/* line pos loop to find the line position*/
file << fromfile;
close (file);
} while ((!eof(file)) || (loop 1= 1));

as I said before this will probably be buggy because I haven't compiled
it nor have I used this since 2 years ago.
but that kinda method would be optimal in my mind, it might be a tad
slow because it reads every line in there up to the matching line.
But it will work after some debugging.

Ronny Iversen wrote:
> Hi :)
> Can anybody tell me whats the most efficient way of reading a file,
> stripping a line from it, and writing  the new result over
> the old file. Is it possible to do this without having to read the
> entire file into an array into memory first?
> Please gimmme some oseudo code or something :)
> Regardz
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      | |
>      +------------------------------------------------------------+

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST