By far the easiest method (presuming that the replacement may be longer) is to read the file up to the string, writing it to a temp file in the process, put the replacement string in the temp file, copy the remainder to the temp file, delete the original, and rename the temp with the original name. Editing a file "in place" is not a trivial undertaking unless you get into raw file handling instead of using the OS.

I would say, just as a personal observation, that when a person is seeking solutions for a particular language, they are not extremely interested in being directed to use another. Difficulty in understanding a particular part of a language is not often best attacked by throwing in the towel and switching to Perl, Python, or Haskell, despite their sometimes easier approaches, via added abstractions.

thanks DaWei,
i have done that part what u told..i.e. copying that to a sting and replacing there and then fwrite() to the original file... but how can i do that without copying ???
and one more thing.. sorry if it is silly.. i cant see the threads started by me !!!!! what to do for this... thats y by mistake have posted the thread twice....