Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <Windows.h>
- using namespace std;
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- ifstream fin;
- fin.open("file.txt");
- ofstream fout;
- fout.open("temp.txt");
- if (!fin.is_open() || !fout.is_open()) {
- cout << "Ошибка открытия файла" << endl;
- }
- else {
- // 1 вариант
- char ch;
- while (fin.get(ch)) {
- if (ch >= 'А' && ch <= 'Я') {
- ch += 32;
- }
- fout << ch;
- }
- // 2 вариант
- /* string str;
- while (getline(fin, str)) {
- for (int i = 0; i < str.size(); i++) {
- if (str[i] >= 'А' && str[i] <= 'Я') {
- str[i] += 32;
- }
- }
- fout << str << endl;
- }*/
- fin.close();
- fout.close();
- remove("file.txt");
- rename("temp.txt", "file.txt");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement