-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilecreator.cpp
45 lines (37 loc) · 930 Bytes
/
filecreator.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
38
39
40
41
42
43
44
45
#include <iostream>
#include <string>
#include <fstream>
int main()
{
bool exit = false;
while(!exit)
{
std::string name;
std::string content;
std::ofstream outfile;
int option;
std::cout << "Menu:" << std::endl;
std::cout << "[1] Create a new file" << std::endl;
std::cout << "[2] Exit" << std::endl;
std::cout << "FileCreator > Please choose an option: ";
std::cin >> option;
switch (option)
{
case 1:
std::cout << "FileCreator > Enter the name of the file: ";
std::cin >> name;
std::cin.ignore();
std::cout << "FileCreator > Enter the content of the file: ";
std::getline(std::cin, content);
outfile.open(name);
outfile << content << std::endl;
outfile.close();
std::cout << "The file was created successfully!" << std::endl;
break;
case 2:
std::cout << "Exiting out of the application..." << std::endl;
exit = true;
break;
}
}
}