PDA

View Full Version : aiuto!!


ultio
12-03-2003, 18:40
each message to/from the server is in the form of
<length><type><data>
where <length> and <type> are 2 bytes each. <length> specifies the length in
bytes of the <data> portion of the message. Be aware that <length> and <type>
appear to be in little-endian format (least significant byte goes first). For
example, in the C language you would encode the number 1 as
const unsigned char num[2] = { 0x01, 0x00 };
and 256 would be encoded as
const unsigned char num[2] = { 0x00, 0x01 };
:cry: :cry: :confused: :cry: :confused: :confused:


aiuto, come faccio in c++???
mi sembra di aver capito di dover usare l'operatore ^, ma non sono sicuro e del resto poi non so continuare...
non posso creare una costante per 256 mumeri, sarebbe un'idiozia :D
esiste una funzione che fa tutto da sola?
o un modo per crearla?
grazie ;)

PS: scusate l'oggetto un pò stupido, ma non ho trovato di meglio

cionci
12-03-2003, 18:48
I PC sono già little endian...basta assegnare il numero ad un unsigned short...

ultio
13-03-2003, 12:30
e perchè chiede una cosa del genere?
const unsigned char num[2] = { 0x01, 0x00 };

cionci
13-03-2003, 14:12
Perchè in quel modo lì il codice è utilizzabile in calcolatori sia little che big endian...