I've done a similiar function and I have problems.
Code:
int FileCompare (char nomebuffer[], char nomebackup[]){
FILE *namebuffer, *namebackup;
char buffer[MAX_KEY];
char backup[MAX_KEY];
int lineabuffer = 0;
namebuffer = fopen(nomebuffer, "rb");
namebackup = fopen(nomebackup, "rb");
while((fgets(buffer, MAX_KEY, namebuffer)) != NULL){
++lineabuffer;
fgets(backup, MAX_KEY, namebackup);
if (buffer != backup){
printf("Mismatch at line %d\n", lineabuffer);
printf("Buffer -> %sBackup -> %s\n",buffer, backup);
return 1;
}//END IF
}// END WHILE
fclose(namebuffer);
fclose(namebackup);
return 0;
}//END FileCompare
I have to compare 2 text files with written this :
Code:
NvCplDaemon
RUNDLL32.EXE C:\WINDOWS\System32\NvCpl.dll,NvStartup
AdslTaskBar
rundll32.exe stmctrl.dll,TaskBar
I copy the buffer file into a backup file, then I call FileCompare but it says there is allways a mismatch in line 1
output:
Mismatch at line 1:
Buffer -> NvCplDaemon
Backup -> NvCplDaemon
I'm sure the lines are not different coz backup it is a copy of buffer previously done by:
Code:
CopyFile(nomebuffer, nomebackup, FALSE);
any suggestion why the
Code:
if (buffer != backup)
fails?