|go ahead... be a heretic|
Re: updating a fileby IraTarball (Monk)
|on Nov 29, 2001 at 00:21 UTC||Need Help??|
This code 'works' for me, well, for some strange distorted definition of 'works.' I think the problem here is that you are trying to update the current like, but you've just read the current line so the write happens on the next line. What I get when I run this is a horribly garbled header file.
You could do this in a number of ways. The most straight forward would be to open one file for reading, one file for writing, and itterate through the read file, replacing the desired lines as you go.
I didn't actually run this, but it should be close. You might want more descriptive diemessages.
The idiomatic way to do this would be with an 'in place edit' that does the file move for you.
This will save the old file as "header.h.old" for you.
(I did run this code) BTW: The $^I is equivalent to the '-i' switch mentioned above by broquaint
"So... What do all these little arrows mean?"