Strangeness when moving data through an array.
Strangeness when moving data through an array.
- Subject: Strangeness when moving data through an array.
- From: John Draper <email@hidden>
- Date: Tue, 30 Nov 2004 20:55:05 -0800
Hi,
I have a variable (16 bits), it's calue is:
short_val = 258 (Byte 0 = 1, Byte 1=2) of a 2 byte int....
(I'm assuming the order is: MSB first
bcopy(&short_val, &pkt[MSEQ], 2);
So I execute this command, and not surprisingly, I'm getting...
pkt[10] = 01
pkt[11] = 02
Now, I take the data from "pkt" and I want to later stick it into a
16 bit (u_short), and would expect... short_test=258, but
after I execute this statement...
bcopy((u_short)&pkt[MSEQ], &short_test, 2);
short_test = 160
WHY? What's going on? How can I extract data from an array in any
arbitrary
index into it (even or odd), and still get back that 2 byte int correctly?
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden