Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / DarkGDK & C++ File input output help

Years of Service
User Offline
Joined: 23rd May 2012
Posted: 23rd May 2012 16:05
Hi, Im currently working on a game which needs to save certain stats to a file as a kind of save function, I know you can use the C++ file input and output, but to be honest, Im a epic nub at the moment when it comes to coding...

What Im asking is:
- How do I call a function from C++ so that it would save the data from the string in DarkGDK
- How do I get the data from the file back into DarkGDK
- And finally how do I create files/directorys in C++ (Or should I just do that in DarkGDK?

Here is my current code that ive been working on but whenever I try to pull the data from the file it seems to come up with some random characters

Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 23rd May 2012 19:09
Well, I would use the fstream header for this.

using namespace std;
#include <fstream>

You will need to run the program in release mode for this though.
There is another way around that, but I don't remember what it is.

To load the a text file to read, use this:
ifstream some_name("relative location of file");
To load the a text file to write, use this:
ofstream some_other_name("relative location of file");

Then you can say this to load stuff,
Or another way to load stuff is this:

You can read about the fstream here:

Anyway, hope this helps.

Login to post a reply

Server time is: 2020-08-03 16:35:03
Your offset time is: 2020-08-03 16:35:03