codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <cctype> #include <cstddef> // std::size_t #include <direct.h> #include <fstream> #include <iostream> // std::cout #include <string> // std::string using namespace std; string talk(string test), Wel(string open); void Change(), Create(), Find(), Make(), Write(); string choice, File, hello, name, newFolder, one, open, test, user; int main () { for ( int i = 0; i < 5; i++) { Wel("would you like to make a folder or write something?"); getline(cin,hello); Find(); } system("pause"); } string talk(string test) { cout << "File Input : "; getline(cin,test); one = test; return one; } string Wel(string message) { cout << message << endl; return message; } void Create() { cout << "what is the files name?" << endl; cin >> File; fstream inout; inout.open(newFolder + "\\" + File,ios::out | ios::app); inout.close(); } void Find() { string str = hello; for (char& ch : str) ch = tolower(ch); size_t found = str.find("make"); if (found != string::npos) { Make(); Create(); } found = str.find("write"); if (found != string::npos) { Change(); talk(test); Write(); } } void Make() { cout << "What is the name of the new folder" << endl; cin >> newFolder; _mkdir((newFolder.c_str())); } void Write() { fstream inout; inout.open(newFolder + "\\" + File,ios::out | ios::app); inout << one << endl; inout.close(); } void Change() { cout << " current path : " << newFolder << " \\ " << File << endl; cout << " \n would you like to change directories ? Folder (1) , File (2) , both (3), continue(4):"; getline(cin,choice); choice =(atoi(choice.c_str())); switch (choice[0]) { case 1: cout << "Folder :"; getline(cin,newFolder); break; case 2: cout << "File :"; getline(cin,File); break; case 3: cout << "Folder :"; getline(cin,newFolder); cout << "File :"; getline(cin,File); default: break; } }
Private
[
?
]
Run code
Submit