Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!houxm!mtuxo!mtune!mtunf!mtx5c!mtx5d!mtx5a!esg From: esg@mtx5a.UUCP (ed gokhman) Newsgroups: net.lang.c Subject: Re: Simple c question - pointer to array Message-ID: <1338@mtx5a.UUCP> Date: Fri, 30-May-86 17:29:00 EDT Article-I.D.: mtx5a.1338 Posted: Fri May 30 17:29:00 1986 Date-Received: Sun, 1-Jun-86 10:17:59 EDT References: <1483@mmintl.UUCP> <856@bentley.UUCP> <118@rruxg.UUCP> Organization: AT&T Information Systems, Middletown, NJ 07748-4801. Lines: 52 > Ok if i have a struct which is named in a typedef as T, I > know how to get an array of pointers to T: T *a[20]; > what I want is a pointer to an array of T's. Kurt, All you need is to express the declaration in English and then to convert it token by token. If precedence of the i-th token is higher then (i-1)-th the result of translation of first i-1 tokens must be parenthesized. In order of decreasing precedence "valid" English tokens and their C-conversions are (S stands for the string resulting from the previous step in English-C conversion (possibly, parenthesised)): English C -------------------------------------------------- is function returning S () array of N S [ N ] pointer to *S =================================================== For example, English C -------------------------------------------------- X is a pointer to an array of 20 Ts ... a pointer to an array of 20 Ts X an array of 20 Ts *X > precedence of [] is higher then *, so >*X should be parenthesizied. an array of 20 Ts (*X) Ts (*X)[] ... T (*X)[] =================================================== Similarly, "X is a pointer to an array of 10 pointers to functions returning pointers to arrays of 11 int" would be int (*(*(*X)[10])())[11]