Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- int nline;
- cout << "Line number to remove (99 - remove everything): ";
- cin >> nline;
- if (nline == 99) {
- ofstream clear("Input.txt");
- clear.close();
- } else {
- ifstream input("Input.txt");
- ofstream tmp("Tmp.txt");
- string line;
- for (int i = 1; getline(input, line); i++) {
- if (nline != i) {
- tmp << line << endl;
- }
- }
- input.close();
- tmp.close();
- remove("Input.txt");
- rename("Tmp.txt", "Input.txt");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment