Работа с файлами на C++, совпадают ли строки?

Дано два текстовых файла. Выяснить, совпадают ли их строки. Если нет, то вывести несовпадающую строку из каждого файла. Не могу понять почему выводит полностью тексты двух файлов

#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <string>
#include <stdio.h>
using namespace std;


int main()
{
    srand(time(NULL));

    FILE *file_open;
    FILE *file_open2;
    fopen_s(&file_open, "text1.txt", "r");
    fopen_s(&file_open2, "text2.txt", "r");
    if (file_open == nullptr||file_open2 == nullptr)
    {
        cout << " file not open/n";
        return 0;
    }
    char* buff1 = new char[100];
    char* buff2 = new char[100];
    while (!feof(file_open))
    {
        fgets(buff1, 100, file_open);
        fgets(buff2, 100, file_open2);
        if (strcmp(buff1, buff2) != 0)
        {
            cout << "Tekst #1 " << buff1 <<"\n";
            cout << "Tekst #2 " << buff2;
        
        }
        cout << endl;
    }
    fclose(file_open);
    fclose(file_open2);
    




    system("pause");
    return 0;
}

Ответы (0 шт):