Is it possible to stop scanning from file in the middle of the file? For example if I want to change this code to for loop with size/2.
edit: Can you please help me understand why i != toScan size(secondSize)?
fseek(toScan, 0, SEEK_END);
secondSize = ftell(toScan);
rewind(toScan);
fseek(toScan, 0.5 * secondSize, SEEK_SET);
while (fgetc(toScan) != EOF){
rewind(signature);
fseek(toScan, -1, SEEK_CUR);
if (fgetc(toScan) == fgetc(signature)){
fseek(toScan, -1, SEEK_CUR);
temp = ftell(toScan);
elements = fread(secondBuffer, 1, size, toScan);
fseek(toScan, temp + 1, SEEK_SET);
if (strcmp(secondBuffer, buffer) == 0){
toReturn = 3;
break;
}
}
rewind(signature);
strncpy(secondBuffer, "", sizeof(secondBuffer));
i++;
}