I'm opening a file with fopen and "r+a"
and after a while i'm trying to add strings that way:
Expand|Select|Wrap|Line Numbers
- char *line = (char *) malloc(MAX_LINE);
- while (fgets(line, sizeof(line), theFile) != NULL)
- if (strstr(line, "I want to append here") != NULL)
- fputs("My new string", theFile);
example:
origin file:
a
b
c
I want to append here
d
e
ffffffffffffffffffffffffffff
overwrited file
a
b
c
I want to append here
My new string
ffffffffffffffffff
How can I deal with this problem?
Thanks in advanced,
Gil