Advertisement
35657

Untitled

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