Hi all,
I'm having difficulties inserting a string into a text file. Here's my code:
What I am trying to do is insert a string after a certain character. This code does not work for some reason, when it goes through the file and finds this specific character, it will not insert my string, but continue to the next character.Code:int main() { FILE *f; char c=0; int br=0; if ((f=fopen("fajl.htm", "r+"))==NULL) { exit(1); } while ((c=fgetc(f))!=EOF) { if (c=='&') { fputs("blah", f); printf("Job done.\n"); } } fclose(f); return 0; }
What am I doing wrong?