the general method for a search& replace that I would use is something like: (written in a mix of code and text)
Code:
read "old" & "new" strings
create temp buffer of size strlen(old)+1
read in first strlen(old) characters to buffer
while (c=getc(input)!=EOF)
{
if (strcmp(buffer,old)==0)
{
print new to output
clear buffer
load the next strlen(old) chars
}else{
write first char of buffer to output
shuffle all chars of buffer down one
read in next char from input to last char of buffer
}
we now have the whole of output printed, with the changes, except for the last (strlen(old)) characters, which are in the buffer.
Check if buffer == old, if so write new, otherwise just print buffer to output and close.
hope that's roughly intelligible
-mark