Good point, but the thing would segfault as originally written anyway if it was non-aligned. I had assumed OP knew that already and would've accounted for that. Thanks for the correction, though.
----- Original Message ----- From: "Dave Carrigan" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[EMAIL PROTECTED]> Sent: Friday, October 04, 2002 8:08 AM Subject: Re: Converting to UIn16 > On Thu, 2002-10-03 at 14:18, William Chow wrote: > > 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. > > And your program will segfault 50% of the time, depending on the length > of the string that precedes the two-byte integer. The best way to get a > UInt16 back from a location that is not necessarily aligned on an even > boundary is > > UInt16 dest; > Char* source > MemMove(&dest, source, sizeof(dest)); > > -- > Dave Carrigan > Seattle, WA, USA > [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 > UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL > > Dave is currently listening to Blues Traveler - Ivory Tusk (Travelers & > Thieves) > > > -- > 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/
