Quote:
while(f1!=NULL && f2!=NULL)
This is NOT a good stop condition while reading files.
When the end-of-file is reached, its FILE pointer doesn't become NULL.
The end-of-file condition is signaled by the
getc()
return value being
EOF
(see
"getc" ).
Change from
Quote:
while(f1!=NULL && f2!=NULL)
{
ch1 = getc(f1);
ch2 = getc(f2);
if(ch1==ch2)
to
while(1)
{
ch1 = getc(f1);
ch2 = getc(f2);
if (ch1 == EOF || ch2 == EOF) break; if(ch1==ch2)