shared memory question/ array of structures

Chris Torek chris at mimsy.umd.edu
Sat Oct 6 14:48:00 AEST 1990


>In article <628 at ge1ccj.Quotron.com> jeff at ge1ccj.Quotron.com (jeff marder)
asks:
>>Suppose I want to define a shared memory segment that is an array of
>>structures.  Do I need to declare the array of structures in my program,
>>or only a pointer to an array of structures to make a shared memory
>>attach?

In article <1990Oct05.182804.27340 at virtech.uucp> cpcahil at virtech.uucp
(Conor P. Cahill) answers:
>You could use an array of pointers to shared memory locations or
>a pointer to an array of structures.

Or, more likely what is desired, you could use a pointer to a (single)
structure.  One of the keys to understanding C arrays and pointers is
the fact that a pointer that points *to* any single element of any array
may be used to access *any* element of that array.  If p points to
element 3 of array `a', then p `points at' ALL of a, and a[2] can be
obtained by naming p[-1] and a[111] can be obtained by naming p[98].
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list