Just for the record, here's the C++ STL implementation for a little more tidiness
#include <fstream> // std::ofstream and std::ifstream
#include <string.h> // strcpy
void DarkGDK ( void )
std::ofstream outfile("MySuperText.txt"); // will overwrite any existing file
int aaa = -111;
outfile << aaa << std::endl; // writes -111 and a new line to text file
outfile << "good" << std::endl; // writes "good" and a new line to text file
outfile << "apple" << std::endl; // writes "apple" and a new line to text file
std::string string1, string2;
infile >> bbb; // reads -111 and converts it to int
infile >> string1; // reads "good" and converts to std::string
infile >> string2; // reads "apple" and converts to std::string
dbText (10,10,buffer); //Print number -111
dbText (10,20,const_cast<char*>(string1.c_str())); //Print word "good"
dbText (10,20,const_cast<char*>(string2.c_str())); //Print word "apple"
dbSync ( );
is a memory safe dynamically allocated string. You can use it just like you used it in DBP.
You can get a const char* from an std::string with:
std::string string1 = "hello world!"
const char* cMyString = myString.c_str();
But because DarkGDK failed to be const correct, dbText() accepts only a char*, so you are forced to cast away the qualifiers:
dbText(10, 10, const_cast<char*>(string1.c_str()));
That gets a little ugly I suppose, but it's not your fault. Alternately, you can copy the string into a buffer before printing it, just like what you'd do with integers:
char buffer; // make absolutely sure the string is not longer than the buffer size
sprintf(buffer, "%s", string1.c_str());
dbText(10, 10, buffer);
I like offending people. People who get offended should be offended. -- Linux Torvalds