Hello. I am trying to find out how to write a function to replace a string in a text file. So far i got this:
find -> is a word i am looking for replace, rep -> new word, f1 -> my file. And i'm stuck with that piece of code:
while ( fgets( buff, BUFSIZ, f1 ) != NULL ) {
if ( strstr( buff, find ) != NULL ) {...
so i'm thinking about something like that:
strcpy(buff2, (buff - strlen(find) + strlen(rep) + 1);
fputs(buff2, f2)
where f2 is output file. So plz, maybe anyone can help me with this code?