char buf[256]; // somewhere a string buffer big enough
...
sprintf(buf,"My Age is %i",MyAgeInt);
dbOpenToWrite ( 1, "file.txt" );
dbWriteString ( 1,buf);
dbCloseFile(1);
I recommend you use this though for file handles. (I have this code in a class, simply remove the
JGC_FILE:: to use
as a pure function, but you MIGHT need to rename if you get a conflict. Idea being, to stop using the hardcoded Filehandles as soon as possible, because eventually you'll need a more dynamic approach.
//----------------------------------------------------------------------------
int JGC_FILE::FreeFile(void){
//----------------------------------------------------------------------------
int r=0; int i=1;
do{
int fh=dbFileOpen(i);
if(fh!=1){
r=i;
};
i++;
}while(r==0 && i<=32);
return r;
};
//----------------------------------------------------------------------------
Your issue is a linking thing with DarkGDK. Lilith told me you need to go into the project properties and change the /MTD to MD or something.. something about DarkGDK didn't supply a debug lib for us to use, and that causes the RELEASE window lib's (like IO) to not link correctly or something. So, I'll let you google this site for LINKING STDLIB IO and anything else you think of.. but it has to do with setting a flag in the linker options so that RELEASE versions of the STDLIB's compile is as RELEASE versions and not the DEBUG ones or something.
I personally don't minf the DarkGDK fileio - just to avoid linking issues... I just wish they had an "OpenForAppend" and an Append that didn't drop the Carriage Return/Line Feed, followed by null... which is fine for reading/writing strings "safely" but sometimes you might be making a file for another kind of system and nulls in text files isn't exactly standard and writing bytes to accomplish same thing is inherently slower...
Overall though I like them. If they had added simply OpenForAppend, that would help ALOT for me anyways...
Example: I have two log files.. one is a REAL LOG FILE... and appending errors makes sense. Open, append line, close... but I've had to resort to leaving file open and making it "start empty each run" and the other one, I don't mind at all being open all the time, its a message log for my GUI I'm making... I can easily track GUI "MESSAGES" and debug a little by seeing if stuff is happening out of order if a problem baffles me.
Good Luck Man!