Path: utzoo!attcan!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: Array of pointers (in general) Message-ID: <1989Dec4.040622.29880@virtech.uucp> Date: 4 Dec 89 04:06:22 GMT References: <10468@attctc.Dallas.TX.US> Distribution: na Organization: Virtual Technologies Inc. Lines: 34 In article <10468@attctc.Dallas.TX.US>, bobc@attctc.Dallas.TX.US (Bob Calbridge) writes: > Example: I want 10 uninitialized structures defined but I want to reference > them through an array of pointers. Rather than give each structure a name > and declare the array like > > struct entry *list [] = { > &S1, &S2, &S3, &S4 > }; > > can I avoid having to declare the structures S1, S2, etc. elsewhere in the > program? You could just do a struct entry list[10]; and not use pointers at all. Or, if you really need to use pointers you could do: #define CNT 10 struct entry *list[CNT]; struct entry reallist[CNT]; and somewhere in the begining of your program do: for(i=0; i < CNT; i++) list[i] = reallist+i; -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+