🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4298

Re: REQ: Help with structs - accessing data

#4298
From: Larry Jones
Date: Sun, 29 Oct 1995 17:43
16 lines
1230 bytes
In article <46t5tb$ad0@wolfe.wimsey.com>, wnight@vanbc.wimsey.com (William Robert Night) writes:
> The basic idea is, read 256 bytes of data that form a packet into a 
> buffer. Point a struct * at it and read data out in a structured fashion.
>  
> The problem is that I can't line things up properly... my compiler 
> (TC++3.0 for msdos) seems to put chars in two bytes of storage.

That's right -- you can't.  Compilers are pretty much allowed to add any
amount of padding they want between structure members and after the last
member (but not before the first one).  If you want your code to be
portable, you pretty much have to bust the packet apart yourself using a
char *.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com
I think my cerebellum just fused. -- Calvin
Technical Details
Message-ID: <470efs$lud@info1.sdrc.com>
Path: arc1-ca.pugleaf.net!sdrc.com!thor!scjones
References: <46t5tb$ad0@wolfe.wimsey.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sdrc.com!thor!scjones
From: larry.jones@sdrc.com (Larry Jones)
Newsgroups: comp.std.c
Subject: Re: REQ: Help with structs - accessing data
Date: 29 Oct 1995 17:43:24 GMT
Organization: SDRC Engineering Services
Distribution: world
Message-ID: <470efs$lud@info1.sdrc.com>
References: <46t5tb$ad0@wolfe.wimsey.com>
NNTP-Posting-Host: thor.sdrc.com
Originator: scjones@thor