Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: shared memory question/ array of structures Message-ID: <26877@mimsy.umd.edu> Date: 6 Oct 90 04:48:00 GMT References: <628@ge1ccj.Quotron.com> <1990Oct05.182804.27340@virtech.uucp> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 >In article <628@ge1ccj.Quotron.com> jeff@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@virtech.uucp> cpcahil@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@cs.umd.edu Path: uunet!mimsy!chris