-
Notifications
You must be signed in to change notification settings - Fork 0
/
notepad.cpp
37 lines (34 loc) · 951 Bytes
/
notepad.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string text;
string name;
cout << "Insert name with .txt extension (eg. name.txt)";
getline(cin, name);
if (name == "con.txt") {
cout << "Can't write to file";
return 1;
} else if (name == "aux.txt") {
cout << "Can't write to file";
return 1;
} else if (name == "prn.txt") {
cout << "Can't write to file";
return 1;
} else if (name == "con") {
cout << "Can't write to file";
return 1;
} else if (name == "aux") {
cout << "Can't write to file";
return 1;
} else if (name == "prn") {
cout << "Can't write to file";
return 1;
}
ofstream file(name);
cout << "Insert text down here, when finished press enter" << endl;
getline(cin, text);
file << text;
return 0;
}