Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 1999 00:14:24 +0200
From:      Iani Brankov <ian@bulinfo.net>
To:        Mark Turpin <mturpin@saturn.spel.com>
Cc:        Freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Programming Question
Message-ID:  <36EC34C0.13D218B4@bulinfo.net>
References:  <Pine.BSF.4.05.9903141646550.6443-100000@saturn.spel.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Mark Turpin wrote:
> 
> I feel really silly having to ask this.
> 
> Why does my sizeof(mystruct) come out as 4 instead of 3 ( short + char ) ?
> 
>         struct {
>            short        shortvariable;
>            char         charvariable;
>         } mystruct;
> 
>         sizeof(mystruct) == 4

Try finding the addresses of the structure members. As I know the compiler
aligns every variable at even address. Maybe that's the reason.

--iani


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36EC34C0.13D218B4>