[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] pakke/udpakke data på bit niveau



Kim Schulz wrote:
hejsa
jeg har en void* som peger på et dataelement som består af:

[bit][bit][bit][int][int][int][int]


Den vil jeg gerne have lagt ind i en struktur, men er blevet lidt i tvivle om det er sikkert at gøre som jeg gør det nu. min struktur: struct type1{ unsigned int type:3; int ordrenr; int varennr; int antal; int hylde; }Type1; Type1 = (struct *type1)data; ret = Type1;


kan dette lade sig gøre eller er jeg helt galt på den?

Du skrive at du har et dataelement der består af: [bit][bit][bit][int][int][int][int] Hvordan er dette mere eksakt defineret? Hvor er der padding? Hvor meget fylder de 'int' du har i dit data-element?

Kort sagt, det er nødvendigt at kende den eksakte struktur af dit data-element og faktisk også om det er dannet af en big-endian eller little-endian maskine og om du læser strukturen ind på en big-endian eller little-endian maskine.

Når du roder med bit, skal man holde tungen lige i munden og kende en del til hvordan bittene placeres i memory!

Med venlig hilsen
Egon Andersen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:10 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *