1
두 파일을 비교하고 두 번째 파일이 첫 번째 파일에 있는지 확인하는 프로그램을 만들려고했습니다. r_scan 함수는 무한 루프가됩니다. 누군가가 왜 작동하지 않는지 알고 있습니까? fseek
의 매뉴얼 페이지 말한다무한 루프 - C 프로그래밍
/**
The function scan the file and check if there is a virus in the file.
Input:
virus_address - The address of the virus file.
scaned_address - The adress of the file that we scan.
Output:
end - If the the file infected. 0 - infected, 1 - not infected.
**/
int r_scan(char* virus_address, char* scaned_address)
{
//INIT
char v = ' ', s = ' ';
int end = 1, i = 0;
long seek = 0;
FILE* vp = NULL;
FILE* sp = NULL;
//Open th5e files.
vp = fopen(virus_address, "rb");
sp = fopen(scaned_address, "rb");
fseek(vp, 0, SEEK_SET);
fseek(sp, 0, SEEK_SET);
//pre scanning
seek = 0;
//Check if the file infected.
while (!(feof(sp)) && end)
{
fread(&s, 1, 1, sp);
if (v == s)
{
v = fgetc(vp);
}
else
{
seek++;
fseek(vp, 0, SEEK_SET);
fseek(sp, seek, SEEK_SET);
fread(&v, 1, 1, vp);
}
if (v == EOF)
{
end = 0;
}
}
fclose(vp);
fclose(sp);
return end;
}
"바이러스 스캐너": D –
'fread (& s, 1, 1, sp);로 "pre scaning"이란 무엇을 의미합니까? – VolAnd
나는 그것을 바꾸는 것을 잊어 버렸습니다. – liad