string replace in file using C
Posted
by Hristo
on Stack Overflow
See other posts from Stack Overflow
or by Hristo
Published on 2010-04-20T04:39:23Z
Indexed on
2010/04/20
4:43 UTC
Read the original article
Hit count: 394
I haven't yet implemented this, I'm still in the thinking stage, but I have to go through a file and replace a certain string with another string. For example,
<img src="/images/logo.gif" ...
should become
<img src="/proxy/www.example.com/images/logo.gif" ...
Any advice on how I can approach this? Perhaps there exist some "string replace" C functions that would do this for me that I don't know about...?
Right now, if I had to write this function myself, I would give it as parameters the file, string to replace, replacement string. Then I would manually go through the file and look for an occurrence of the string and recreate it. This, however, seems very inefficient. Are there better ways to do this?
Thanks, Hristo
© Stack Overflow or respective owner