Code: Select all
while((fgets(line, 1024, fp) != NULL) && (line[0] != '\0')) {
if(strncmp("-enabled", line, 8) == 0) {
printf("Line: %s", line);
}
}
Thanks for any help you guys can give me.
Code: Select all
while((fgets(line, 1024, fp) != NULL) && (line[0] != '\0')) {
if(strncmp("-enabled", line, 8) == 0) {
printf("Line: %s", line);
}
}
Code: Select all
FILE * infile;
FILE * outfile;
char * tmpFileName;
char line[128];
infile = fopen("somefile.txt","r");
tmpFileName = tmpnam(NULL);
outfile = fopen(tmpFileName,"w");
while(fgets(line, sizeof(line), infile)) {
if(strcmp(line,"sometext") == 0)
strcpy(line, "someOtherText");
fputs(line,outfile);
}
fclose(infile);
fflush(outfile);
fclose(outfile);
remove("somefile.txt");
rename(tmpFileName,"somefile.txt");

