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 {
- string str;
- getline(fin, str);
- if (!fin.eof()) {
- fout << str;
- }
- while (getline(fin, str)) {
- if (!fin.eof()) {
- fout << endl << str;
- }
- }
- fin.close();
- fout.close();
- remove("file.txt");
- rename("temp.txt", "file.txt");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement