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 / Reading/Writing a file

Author
Message
Mister Fuzzy
13
Years of Service
User Offline
Joined: 27th Feb 2011
Location: XNA
Posted: 2nd Jul 2012 01:21
Just a quick question: After reading or writing a byte of info, does the file automatically skip to the next byte or do I have to insert dbSkipBytes to do this manually?

ALIEN(S)!!!!!!!!1!! (and sausages)
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 2nd Jul 2012 22:25
It skips automatically. Remember, you can always test things like this by writing a custom file and then reading it.


Mister Fuzzy
13
Years of Service
User Offline
Joined: 27th Feb 2011
Location: XNA
Posted: 9th Jul 2012 22:10
Yeah, I could've, but I was nowhere near a computer with DGDK when I posted this...

And did I miss something, or are the file commands broken? With the code
only results in an empty file! Is my DGDK broken?

ALIEN(S)!!!!!!!!1!! (and sausages)
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 10th Jul 2012 15:18
You would be much better off using stdio.h or (I don't know yet) fstream. At least in stdio you can use binary files using "rb" for read binary or "wb" for write binary. They also allow for formatted output using the fprintf()...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 12th Jul 2012 16:12
Yes. stdio.h is overall the best way to load/save info. You can even use it with data structures/classes. The db file functions are limited in their data types.

Here's a link if you need to read up on it:
http://www.cplusplus.com/reference/clibrary/cstdio/fopen/

The fastest code is the code never written.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Jul 2012 18:15
I agree that you probably want to use one of the C++ standard file managing libraries, however to answer your question dbMakeFile creates an empty file and dbOpenToWrite will also create a new file, failing if the provided file name already exists. In other words you don't want to use dbMakeFile there.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-11-19 00:51:53
Your offset time is: 2024-11-19 00:51:53