extrn

Untitled

Feb 7th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int nline;
  8.     cout << "Line number to remove (99 - remove everything): ";
  9.     cin >> nline;
  10.  
  11.     if (nline == 99) {
  12.         ofstream clear("Input.txt");
  13.         clear.close();
  14.     } else {
  15.         ifstream input("Input.txt");
  16.         ofstream tmp("Tmp.txt");
  17.         string line;
  18.  
  19.         for (int i = 1; getline(input, line); i++) {
  20.             if (nline != i) {
  21.                 tmp << line << endl;
  22.             }
  23.         }
  24.  
  25.         input.close();
  26.         tmp.close();
  27.         remove("Input.txt");
  28.         rename("Tmp.txt", "Input.txt");
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment