I am currently trying to figure my way how to output strings to a file.
I have seen all the many posts and such how to do it in a console program, and have had much success doing it that way. This is a gui app though. What I want to be able to do is take strings from a text box, output those strings to char arrays, and then output the char arrays to a text file. Here is what I have so far:
void __fastcall TForm1::Button1 Click(TObject *Sender)
{
class Key //initialize the classes
{
public:
AnsiString user;
AnsiString host;
AnsiString userid;
AnsiString date;
AnsiString dir;
};
class Charz
{
public:
char user;
char host;
char userid;
char date;
char dir;
};
Key MyKey; //string variables
MyKey.user = User->Text; //get strings from text boxes
MyKey.host = Host->Text;
MyKey.userid = UserID->Text;
MyKey.date = Date_Time_Box->Text;
MyKey.dir = File_Dir->Text;
Output->Lines->Add(MyKey.user ); //output strings to textbox in order that input into file
Output->Lines->Add(MyKey.host );
Output->Lines->Add(MyKey.user id);
Output->Lines->Add(MyKey.date );
Output->Lines->Add(MyKey.dir) ;
Output->Lines->Add("User Input Complete");
Charz KeyChar; //char variables
KeyChar.user;
KeyChar.host;
KeyChar.userid;
KeyChar.date;
KeyChar.dir;
ofstream outputFile("use r.gen"); //output file
fstream inputFile;
outputFile << KeyChar.user << "\n"; //char variables to file
outputFile << KeyChar.host << "\n";
outputFile << KeyChar.userid << "\n";
outputFile << KeyChar.date << "\n";
outputFile << KeyChar.dir << "\n";
outputFile.clos e();
Output->Lines->Add("User Settings Written to file");
Output->Lines->Add("Generatin g Keys....");
}
It is just a matter of getting the strings in MyKey into the chars in KeyChar.
I have seen all the many posts and such how to do it in a console program, and have had much success doing it that way. This is a gui app though. What I want to be able to do is take strings from a text box, output those strings to char arrays, and then output the char arrays to a text file. Here is what I have so far:
void __fastcall TForm1::Button1 Click(TObject *Sender)
{
class Key //initialize the classes
{
public:
AnsiString user;
AnsiString host;
AnsiString userid;
AnsiString date;
AnsiString dir;
};
class Charz
{
public:
char user;
char host;
char userid;
char date;
char dir;
};
Key MyKey; //string variables
MyKey.user = User->Text; //get strings from text boxes
MyKey.host = Host->Text;
MyKey.userid = UserID->Text;
MyKey.date = Date_Time_Box->Text;
MyKey.dir = File_Dir->Text;
Output->Lines->Add(MyKey.user ); //output strings to textbox in order that input into file
Output->Lines->Add(MyKey.host );
Output->Lines->Add(MyKey.user id);
Output->Lines->Add(MyKey.date );
Output->Lines->Add(MyKey.dir) ;
Output->Lines->Add("User Input Complete");
Charz KeyChar; //char variables
KeyChar.user;
KeyChar.host;
KeyChar.userid;
KeyChar.date;
KeyChar.dir;
ofstream outputFile("use r.gen"); //output file
fstream inputFile;
outputFile << KeyChar.user << "\n"; //char variables to file
outputFile << KeyChar.host << "\n";
outputFile << KeyChar.userid << "\n";
outputFile << KeyChar.date << "\n";
outputFile << KeyChar.dir << "\n";
outputFile.clos e();
Output->Lines->Add("User Settings Written to file");
Output->Lines->Add("Generatin g Keys....");
}
It is just a matter of getting the strings in MyKey into the chars in KeyChar.