#include <stdio.h>

#include <string.h>

int main(void)

{
 FILE * fp1 = fopen("test1.txt", "rt");

 FILE * fp2 = fopen("test2.txt", "rt");

 int m1, m2;

 

 if(fp1==NULL || fp2 == NULL)

 {

  printf("파일오픈에러");

  return -1;

 }

 

 

 while((m1 = fgetc(fp1)) != EOF && (m2 = fgetc(fp2)) != EOF)

 {
  if(m1!=m2)

  {

   printf("두 파일은 서로 다릅니다");

   return -1;

  }

 }
 
 printf("두 파일은 서로 같습니다n");


 fclose(fp1);

 fclose(fp2);

 return 0;

}





텍스트 파일 하나에는
a
b
c
다른 파일에는
a
b
c
d


로 저장해놨는데 왜 서로 같다고 나올까