when i use this script and choose "2" or "3" (in bold) it closes automatically, but "1" (underlined) doesn't
#include <fstream>
#include <iostream>
#include <iostream>
using namespace std;
int main()
{
char str[10];
char FileName[500];
char FileContents[999999];
char usernameb[99];
char username[99];
char FileExt[99];
char ExtensionName[500];
char fullnamew[500];
int Choice;
int Choice2;
cout<<"~~File Name~~\n";
cout<<"Enter The File Name\n";
cin.getline ( FileName, 500 );
cout<<"\n~~File Contents~~\n";
cout<<"Enter The File Contents\n";
cin.getline ( FileContents, 999999 );
cout<<"\n~~Save Directory~~";
//cout<<"Type File Extension";
//cin.getline ( FileExt, 99 );
cout<<"Type...\ n";
cout<<"1. To Save File On Desktop\n";
cout<<"2. To Save File In My Documents\n";
cout<<"3. To Type In Your Own Location\n";
cin>> Choice;
cin.ignore();
if ( Choice == 1 ) {
string FileRoot("C:/Documents and Settings/All Users/Desktop/");
string root = FileRoot;
cout<<"\n~~File Extension~~";
cout<<"\nPress. ..\n";
cout<<"1. Text Format\n";
cout<<"2. HTML Format\n";
cout<<"3. Rich Text Format\n";
cout<<"4. Manually Type In Extension...\n" ;
cin>> Choice2;
cin.ignore();
if ( Choice2 == 1 ) {
string fullname = root + "/" + FileName + ".txt";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 2 ) {
string fullname = root + "/" + FileName + ".html";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 3 ) {
string fullname = root + "/" + FileName + ".rtf";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 4 ) {
cout<<"~~Extens ion~~\n";
cout<<"Type In The Extension (ex. '.txt')\n";
cin.getline ( ExtensionName, 500 );
string fullname = root + "/" + FileName + ExtensionName;
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice == 2 ) {
cout<<"What Is Your Username\n";
cin.getline ( usernameb, 999 );
string username = usernameb;
string root = "C:/Documents and Settings/" + username + "/My Documents/";
cout<<"\n~~File Extension~~";
cout<<"\nPress. ..\n";
cout<<"1. Text Format\n";
cout<<"2. HTML Format\n";
cout<<"3. Rich Text Format\n";
cout<<"4. Manually Type In Extension...\n" ;
cin>> Choice2;
cin.ignore();
if ( Choice2 == 1 ) {
string fullname = root + "/" + FileName + ".txt";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 2 ) {
string fullname = root + "/" + FileName + ".html";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 3 ) {
string fullname = root + "/" + FileName + ".rtf";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 4 ) {
cout<<"~~Extens ion~~\n";
cout<<"Type In The Extension (ex. '.txt')\n";
cin.getline ( ExtensionName, 500 );
string fullname = root + "/" + FileName + ExtensionName;
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice == 3 ) {
cout<<"Type In The Directory (ex. 'C:/Documents and Settings/Bob/My Documents/\n";
cin.getline ( usernameb, 999 );
string username = usernameb;
string fullname = username + "/" + FileName + ".txt";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); \
}
// cin.getline ( usernameb, 999 );
// string username = usernameb;
}
cin.get();}}
#include <fstream>
#include <iostream>
#include <iostream>
using namespace std;
int main()
{
char str[10];
char FileName[500];
char FileContents[999999];
char usernameb[99];
char username[99];
char FileExt[99];
char ExtensionName[500];
char fullnamew[500];
int Choice;
int Choice2;
cout<<"~~File Name~~\n";
cout<<"Enter The File Name\n";
cin.getline ( FileName, 500 );
cout<<"\n~~File Contents~~\n";
cout<<"Enter The File Contents\n";
cin.getline ( FileContents, 999999 );
cout<<"\n~~Save Directory~~";
//cout<<"Type File Extension";
//cin.getline ( FileExt, 99 );
cout<<"Type...\ n";
cout<<"1. To Save File On Desktop\n";
cout<<"2. To Save File In My Documents\n";
cout<<"3. To Type In Your Own Location\n";
cin>> Choice;
cin.ignore();
if ( Choice == 1 ) {
string FileRoot("C:/Documents and Settings/All Users/Desktop/");
string root = FileRoot;
cout<<"\n~~File Extension~~";
cout<<"\nPress. ..\n";
cout<<"1. Text Format\n";
cout<<"2. HTML Format\n";
cout<<"3. Rich Text Format\n";
cout<<"4. Manually Type In Extension...\n" ;
cin>> Choice2;
cin.ignore();
if ( Choice2 == 1 ) {
string fullname = root + "/" + FileName + ".txt";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 2 ) {
string fullname = root + "/" + FileName + ".html";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 3 ) {
string fullname = root + "/" + FileName + ".rtf";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 4 ) {
cout<<"~~Extens ion~~\n";
cout<<"Type In The Extension (ex. '.txt')\n";
cin.getline ( ExtensionName, 500 );
string fullname = root + "/" + FileName + ExtensionName;
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice == 2 ) {
cout<<"What Is Your Username\n";
cin.getline ( usernameb, 999 );
string username = usernameb;
string root = "C:/Documents and Settings/" + username + "/My Documents/";
cout<<"\n~~File Extension~~";
cout<<"\nPress. ..\n";
cout<<"1. Text Format\n";
cout<<"2. HTML Format\n";
cout<<"3. Rich Text Format\n";
cout<<"4. Manually Type In Extension...\n" ;
cin>> Choice2;
cin.ignore();
if ( Choice2 == 1 ) {
string fullname = root + "/" + FileName + ".txt";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 2 ) {
string fullname = root + "/" + FileName + ".html";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 3 ) {
string fullname = root + "/" + FileName + ".rtf";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice2 == 4 ) {
cout<<"~~Extens ion~~\n";
cout<<"Type In The Extension (ex. '.txt')\n";
cin.getline ( ExtensionName, 500 );
string fullname = root + "/" + FileName + ExtensionName;
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); }
if ( Choice == 3 ) {
cout<<"Type In The Directory (ex. 'C:/Documents and Settings/Bob/My Documents/\n";
cin.getline ( usernameb, 999 );
string username = usernameb;
string fullname = username + "/" + FileName + ".txt";
ofstream a_file(fullname .c_str());
a_file<<FileCon tents;
a_file.close(); \
}
// cin.getline ( usernameb, 999 );
// string username = usernameb;
}
cin.get();}}
Comment