I had some spare time so I decided to mess around with the generation of files and directories in C++. Here's what I made:
http://pastebin.com/5HdtJBMy
[C]#include <Windows.h>
#include <iostream>
#include <fstream>
#include <ostream>
void main(void)
{
char test_1;
char test_2;
std:
fstream created_file;
while(true)
{
std::cout << "Hello! This program will create a directory in the Program Files (x86) folder\non your computer." << std::endl;
std::cout << "Do you wish to continue? Y for yes, N for no." << std::endl;
std::cin >> test_1;
switch(test_1)
{
case 'Y':
case 'y':
break;
case 'N':
case 'n':
std::cout << "The program will now exit then." << std::endl;
system("pause");
exit(0);
default:
std::cerr << "Invalid Input" << std::endl;
exit(0);
}
CreateDirectory(L"C:\\Program Files (x86)\\Created_Directory", NULL);
std::cout << "The directory has been created. This program will now create a file in said\ndirectory. Do you wish to continue?\n Y for yes, N for no." << std::endl;
std::cin >> test_2;
switch(test_2)
{
case 'Y':
case 'y':
break;
case 'N':
case 'n':
std::cout << "The program will now exit then." << std::endl;
system("pause");
exit(0);
default:
std::cerr << "Invalid Input" << std::endl;
exit(0);
}
created_file.open("C:\\Program Files (x86)\\Created_Directory\\Created_file.txt");
created_file << "Automatically generated text. Thank you for using this program. :3";
created_file.close();
std::cout << "The file has been generated." << std::endl;
break;
}
std::cout << "The program will now shut down." << std::endl;
system("pause");
}[/c]
The program informs the user that there will be a directory generated and then asks the user if they wish to continue. They input either Yes or No and the program does a specified action depending on which the user chooses. If the user chooses yes, the program will create a directory in C:\Program Files (x86). If the user chooses no the program exits. Then the program informs the user a file will be generated. It has the same process as above. If the user chooses yes, a text file will be generated in the created directory. After the text file is generated, the program closes.
:dirol:
http://pastebin.com/5HdtJBMy
[C]#include <Windows.h>
#include <iostream>
#include <fstream>
#include <ostream>
void main(void)
{
char test_1;
char test_2;
std:
while(true)
{
std::cout << "Hello! This program will create a directory in the Program Files (x86) folder\non your computer." << std::endl;
std::cout << "Do you wish to continue? Y for yes, N for no." << std::endl;
std::cin >> test_1;
switch(test_1)
{
case 'Y':
case 'y':
break;
case 'N':
case 'n':
std::cout << "The program will now exit then." << std::endl;
system("pause");
exit(0);
default:
std::cerr << "Invalid Input" << std::endl;
exit(0);
}
CreateDirectory(L"C:\\Program Files (x86)\\Created_Directory", NULL);
std::cout << "The directory has been created. This program will now create a file in said\ndirectory. Do you wish to continue?\n Y for yes, N for no." << std::endl;
std::cin >> test_2;
switch(test_2)
{
case 'Y':
case 'y':
break;
case 'N':
case 'n':
std::cout << "The program will now exit then." << std::endl;
system("pause");
exit(0);
default:
std::cerr << "Invalid Input" << std::endl;
exit(0);
}
created_file.open("C:\\Program Files (x86)\\Created_Directory\\Created_file.txt");
created_file << "Automatically generated text. Thank you for using this program. :3";
created_file.close();
std::cout << "The file has been generated." << std::endl;
break;
}
std::cout << "The program will now shut down." << std::endl;
system("pause");
}[/c]
The program informs the user that there will be a directory generated and then asks the user if they wish to continue. They input either Yes or No and the program does a specified action depending on which the user chooses. If the user chooses yes, the program will create a directory in C:\Program Files (x86). If the user chooses no the program exits. Then the program informs the user a file will be generated. It has the same process as above. If the user chooses yes, a text file will be generated in the created directory. After the text file is generated, the program closes.
:dirol: