You do the same thing as you did for the byte , you cast it as an unsigned
short.
So just replace 8 with 16. Read up on casting in K&R and the C FAQ (found
online). Should be pretty obvious.


----- Original Message -----
From: "Grosch, Scott" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Thursday, October 03, 2002 1:31 PM
Subject: Converting to UIn16


> OK, sorry for the stupid question here, but....:
>
> Let's say I write a record like this:
>
> UInt16 someNum;
>
> DmStrCopy(record, 0, str);
> DmWrite(record, StrLen(str) + 1, &someNum, sizeof(someNum));
>
>
> When I read it back, I'd do:
>
>
> Char *record = (Char *) MemHandleLock(h);
> record += StrLen(record) + 1;
>
> Now record is at the offset where that UInt16 was written.
> How do I grab that value back into a UInt16?  I've always just
> had a UInt8 before, so I'd just say:  UInt8 n = (UInt8) *record;
>
> a UInt16 is two bytes though, so that's not going to work.  Sorry for
> such a simple question, but I've left my book at home so I can't consult
> it.
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to