sr************@gmail.com wrote:
i want replace one word to another in a file .i am trying to use in
gets
gets() does not read from a file. It is also fatally flawed in its
handling of overflows. *Never* use gets(). Use fgets() to read line.
Use strstr() to find the word. The substitution is trickier.
Consider this line:-
"small elephants hate elephants optics"
To replace "hate" with "love":-
find the "hate"
write the line to another file (use fputs()) until you
reach "hate"
write "love"
write the rest of the line
Give it a try. If you get stuck post what you've written.
--
Nick Keighley