About Store Forum Documentation Contact



Post Reply 
c8 to Char8
Author Message
Brainache Offline
Member

Post: #1
c8 to Char8
Hello - the following function worked correctly before the change of c8 to Char8, but now causes infinite read...
(read a null-terminated string)

I changed the c8's to Char8's... any ideas?


Str c3dw::readStr(File *f)
{

Str txt = "";
Char8 input = ' ';
while (input != '\0')
{
f->get( &input, sizeof(Char8));
txt += input;
}
return txt;
}
06-05-2009 01:06 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: c8 to Char8
please debug and see what's going on
06-05-2009 04:19 PM
Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #3
Re: c8 to Char8
After digging in deeper.. the problem seems to be coming from the getInt() function...
it does not appear to be returning the same values that the getI32() function did.
It is returning values like '59375616' & '' when it should return '20'

Here is the loading code... this was working 100% correctly before the change in the IO functions...
File f;
f.read(filename);
Header.mVersion = f.getUInt(); // returning 14 = correct
Header.mFlags = f.getByte(); // returning 0 = correct
Header.mNameCount = f.getInt(); // returning 59375616.. should be 20


variables are defined as:
U16 mVersion; // should be 14
Byte mFlags;
int mNameCount; ( i've tried I32 & Int as well)

Any suggestions?
06-06-2009 10:23 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
Re: c8 to Char8
I think you've mismatched U16 with UInt

you have
U16 mVersion; // should be 14

but you're reading it
Header.mVersion = f.getUInt();
06-06-2009 10:44 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
Re: c8 to Char8
and for reading strings please use File::putStr and File::getStr
06-06-2009 10:47 PM
Find all posts by this user Quote this message in a reply
Post Reply