🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1186

Re: Question about sizeof in C/C++.

#1186
From: James Cribb
Date: Fri, 01 Jan 1993 02:19
15 lines
1015 bytes
jimad@microsoft.com (Jim Adcock) writes:
>jamesc@swapsdev.state.state.COM.AU (James Cribb) writes:
>| Given
>|     struct Something*  ps;
>|     unsigned  k;
>| do the C or C++ standards guarantee that
>|     &ps[k] == ((char*) ps) + k * sizeof(struct Something)
>
>No.  The relationship holds only if ... k is less than or equal 
>to the number of elements in the array pointed-to by ps

My code meets those conditions, but just out of interest,
if k is too big, what could cause an inequality (of the addresses)?

	j.c
Technical Details
Message-ID: <jamesc.725854759@bart>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!sequoia!state.COM.AU!bart!jamesc
References: <jamesc.724544278@bart> <wwJXVB3w164w@amfent.Gwinnett.COM> <1992Dec24.001540.30000@microsoft.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++,comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!sequoia!state.COM.AU!bart!jamesc
From: jamesc@swapsdev.state.state.COM.AU (James Cribb)
Subject: Re: Question about sizeof in C/C++.
Message-ID: <jamesc.725854759@bart>
Sender: news@state.COM.AU
Organization: Group Treasury, State Bank of NSW
References: <jamesc.724544278@bart> <wwJXVB3w164w@amfent.Gwinnett.COM> <1992Dec24.001540.30000@microsoft.com>
Date:  1 Jan 93 02:19:19 GMT
Lines: 15