Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!purdue!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Array of pointers (in general) Message-ID: <21111@mimsy.umd.edu> Date: 5 Dec 89 16:08:51 GMT References: <10468@attctc.Dallas.TX.US> Distribution: na Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 28 In article <10468@attctc.Dallas.TX.US> bobc@attctc.Dallas.TX.US (Bob Calbridge) asks about having pointers that point to objects that do not have names: >My immediate need requires that I simply establish an array of pointers and >also declare the space to which the pointers point. The data area does not >need to have an initial content but must be reserved. Is this possible ... The answer is `no and yes'. C has only two kinds of unnamed objects, and only one of them is available at compile time. The construct "abc" produces (in all but one special case) an unnamed object of type `array N of char' (here N = 4), and evaluates to a pointer to the first character of that array. The other kind of unnamed object is that returned by malloc(). All other C objects (but not necessarily values) have names. Someone else has already supplied the `yes' part of the answer, in which you declare a single named object of type array N of T, and then set your N pointer-to-T objects to point to each of these objects in turn. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris