35657

Untitled

Dec 2nd, 2023
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <Windows.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     SetConsoleCP(1251);
  10.     SetConsoleOutputCP(1251);
  11.  
  12.     ifstream fin;
  13.     fin.open("C:/Users/PC/Desktop/file.txt");
  14.  
  15.     ofstream fout;
  16.     fout.open("C:/Users/PC/Desktop/file2.txt");
  17.  
  18.     if (!fin.is_open() || !fout.is_open()) {
  19.         cout << "Ошибка открытия файла" << endl;
  20.     }
  21.     else {
  22.  
  23.         char ch;
  24.  
  25.         while (fin.get(ch)) {
  26.             if (ch >= 'А' && ch <= 'Я') {
  27.                 ch += 32;
  28.             }
  29.             fout << ch;
  30.         }
  31.         fin.close();
  32.         fout.close();
  33.         remove("C:/Users/PC/Desktop/file.txt"); // удаляем старый файл
  34.         rename("C:/Users/PC/Desktop/file2.txt", "C:/Users/PC/Desktop/file.txt"); // переименовываем новый файл (называем его именем старого)
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment