Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

лаба по чтению из файла

.txt
Скачиваний:
0
Добавлен:
06.10.2025
Размер:
1.49 Кб
Скачать
#include <fstream>
#include <conio.h>
#include <iostream>
#include <windows.h>
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
void gotoxy(int x, int y)
{
    COORD c;
    c.X = x;
    c.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void Color(char* ukaz)
{
    SetConsoleTextAttribute(hConsole, 12);
    cout << *ukaz;
    SetConsoleTextAttribute(hConsole, 15);
}
using namespace std;
int main(){
    setlocale(LC_ALL, "RUS");
    char ch[150],ch2[150]; // буфер промежуточного хранения считываемого из файла текста
    ifstream fin("1.txt"); //открываем файл и читаем
    int i = 0,y=0;
    while (!fin.eof()) //пока не закончился
    {
        char* ukaz = &ch[i];
        fin.get(ch[i]);
        cout << ch[i];
        i++;
    }
        fin.close();
        cout << endl;
        
    ifstream fin2("2.txt"); //открываем файл и читаем
    int j = 0;
    gotoxy(25, y);
    while (!fin2.eof()) //пока не закрыт
    {
        fin2.get(ch2[j]);
       /* if (ch[i] != ch2[j]) {
                     
        }*/
        else { cout << ch2[j]; }
        if (ch2[j] == '\n') {
            y++;
            gotoxy(25, y);
            continue;
        }
        j++;
    }
    cout << endl;
        fin2.close();
        SetConsoleTextAttribute(hConsole, 15);
    system("pause");
}
Соседние файлы в предмете Программирование на C++