본문 바로가기

SW Study/윤성우 C 프로그래밍

도전! 프로그래밍4 도전5

#include <stdio.h>
#include <string.h>

int main(void)
{
   char ch1, ch2;
   FILE * fp1 = fopen("d1.txt", "rt");
   FILE * fp2 = fopen("d2.txt", "rt");

   if (fp1 == NULL||fp2 == NULL)
   {
      puts("file open error! ");
      return -1;
   }

   while (1)
   {
      ch1 = fgetc(fp1);
      ch2 = fgetc(fp2);

      if (ch1 != ch2)
      {
         printf("Not Coincide \n");
         break;
      }
      else if (ch1 == EOF&&ch2 == EOF)
      {
         printf("Coincide \n");
         break;
      }
   }

   fclose(fp1);
   fclose(fp2);
   return 0;
}