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 a file and Printing it

Author
Message
Ninjateck
16
Years of Service
User Offline
Joined: 27th Feb 2008
Location:
Posted: 1st Oct 2008 04:09
Im trying to read in text from a file and print on the screen
My code is like this


it wont compile for some reason.
even though i know i cant print and integer i get an error
Quote: "
darksdkfile.h(101): could be 'int dbReadFile(int,int *)'"


http://ninjagms.wetpaint.com/
xix psycho xix
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location:
Posted: 1st Oct 2008 06:33 Edited at: 1st Oct 2008 06:36
Well you have to cast the int to a float before you print it, but try using dbReadFile like so:

int a = dbReadFile (FILE_NUM);

when i tried it the first way, i got the same compile error as you, but this way there was no error.

Sorry. what i meant to say was:

dbReadFile (FILE_NUM, &a);

dbReadFile takes a pointer to an integer, so a pointer must be used.
Shadow Fan 0
16
Years of Service
User Offline
Joined: 27th Jan 2008
Location: Livermore, CA
Posted: 9th Oct 2008 22:14
I forget which thread I saw this in, but I remember one of the Dark GDK developers recommending using the C++ File I/O (fstream) as opposed to the Dark GDK ones. Perhaps you might try using that instead?

"...The Protoss do not run from their enemies. Aiur is our homeworld, it is here that we shall make our stand!" -Aldaris
Ninjateck
16
Years of Service
User Offline
Joined: 27th Feb 2008
Location:
Posted: 9th Oct 2008 22:21
I got his code working
actually the first one works better


http://ninjagms.wetpaint.com/
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Oct 2008 23:21
Definitely avoid the GDK file I/O - it's hard to use, inflexible, slow and has no error detection. Use either the C++ stream I/O (http://www.cplusplus.com/doc/tutorial/files.html) or the older but still good C file I/O (http://www.cprogramming.com/tutorial/cfileio.html).

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 9th Oct 2008 23:43
^I highly recommend C++ fstream.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 13th Oct 2008 02:45
C is better. Mainly because I'm a PHP developer.

Login to post a reply

Server time is: 2024-11-25 06:43:35
Your offset time is: 2024-11-25 06:43:35