Path: utzoo!utgpu!watmath!clyde!bellcore!rutgers!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!sco!seanf
From: seanf@sco.COM (Sean Fagan)
Newsgroups: comp.lang.c
Subject: Re: What should "sizeof (expression)" return? Why "8" ??
Keywords: sizeof expression
Message-ID: <1878@scolex>
Date: 7 Dec 88 21:21:50 GMT
References: <654@sbsvax.UUCP>
Reply-To: seanf@sco.COM (Sean Fagan)
Organization: The Santa Cruz Operation, Inc.
Lines: 30
In article <654@sbsvax.UUCP> greim@sbsvax.UUCP (Michael Greim) writes:
[struct mist { int a1:1, a2:16}; int i; float r; char s[20];
>sizeof(mist.a1) [1 bit] = 4
Because an int, on your machine, is 4 bytes long, and mist.a1 is expanded to
an unsigned int.
>sizeof(c1sizeof(i+r) = 8
An integer and a floating point form a floating point expression, which, on
your machine, is 8 bytes.
>sizeof(i+s) = 4
This is a pointer expression (equivalent to &s[i]), and a character pointer
on your machine is 4 bytes long.
>What should "sizeof expression" return?
The size, in char's, of the expression.
--
Sean Eric Fagan | "Engineering without management is *ART*"
seanf@sco.UUCP | Jeff Johnson (jeffj@sco)
(408) 458-1422 | Any opinions expressed are my own, not my employers'.