i am making a program that gets two binary files, and checks if the second file (string) is in the first file. I tried to use strstr function but it doesnt work. This is that part of my code: Am i reading the files right?
fseek(fileToCheckv, 0 , SEEK_END);
size = ftell(fileToCheckv);
rewind(fileToCheckv);
fseek(virusSignit, 0L, SEEK_END);
vsize = ftell(virusSignit);
rewind(virusSignit);
buffer = (char*)realloc(buffer, size+1 * sizeof(char));
virusSig = (char*)realloc(virusSig, vsize+1 * sizeof(char));
buffer[size] = 0;
virusSig[vsize] = 0;
fread(buffer,1 , size, fileToCheckv);
fread(virusSig,1 ,vsize, virusSignit);
result = strstr(buffer, virusSig);
if (result != NULL)
{
printf("\nVirus was found in file: %s\n", fileToOpen);
}
else
{
printf("The virus was not found\n");
}