|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Bannato
Iscritto dal: Feb 2003
Città: genova
Messaggi: 130
|
aiuto!!
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 }; 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 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 |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
I PC sono già little endian...basta assegnare il numero ad un unsigned short...
|
|
|
|
|
|
#3 |
|
Bannato
Iscritto dal: Feb 2003
Città: genova
Messaggi: 130
|
e perchè chiede una cosa del genere?
const unsigned char num[2] = { 0x01, 0x00 }; |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Perchè in quel modo lì il codice è utilizzabile in calcolatori sia little che big endian...
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 07:30.



















