Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!ncar!noao!arizona!naucse!jdc From: jdc@naucse.cse.nau.edu (John Campbell) Newsgroups: comp.lang.c Subject: declaring an array of pointers to malloced arrays Keywords: cdecl, type declarations Message-ID: <2812@naucse.cse.nau.edu> Date: 4 Nov 90 21:23:56 GMT Organization: Northern Arizona University, Flagstaff AZ Lines: 27 Help? I built a structure: typedef struct { int loc, bstart, bend;} seeks; and I want to store a bunch of these seek triples in malloced space. But I also want to be prepared for up to _NFILES number of malloced arrays. What I ended up doing was the following lie: static seeks *fdseeks[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; Then, after mallocing in an init() routine, when I wanted to access the 10'th seek triple for the 3rd file I'd do this ugly trick: seeks *seek_p = (fdseeks[3] + 10*sizeof(seeks)); and seek_p->loc would be the file 3's 10'th seek location. What I'd rather say, however, is fdseeks[3][10]->loc (or even fdseeks[3][10].loc). Note: cdecl warns me that struct seeks (*fdseeks[20])[], with it's arbitrary array ([]) is not supported by the 'C' language. Now remember, BE NICE; some of us morons post to learn, not to start fights! -- John Campbell jdc@naucse.cse.nau.edu CAMPBELL@NAUVAX.bitnet unix? Sure send me a dozen, all different colors.