Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sjuvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!sjuvax!bbanerje From: bbanerje@sjuvax.UUCP (B. Banerjee) Newsgroups: net.lang.c Subject: Re: Help with malloc() ... Message-ID: <461@sjuvax.UUCP> Date: Fri, 17-Aug-84 17:42:50 EDT Article-I.D.: sjuvax.461 Posted: Fri Aug 17 17:42:50 1984 Date-Received: Sun, 19-Aug-84 03:44:43 EDT References: <12365@sri-arpa.UUCP> Organization: Saint Josephs Univ. Phila., Pa. Lines: 37 Hello, I have a similar question which I would appreciate any solutions to. I have a large (working) program involving a two dimensional array that I would like to allocate storage for, dynamically (calloc). I really don't want to go through and change all the array references to do pointer arithmetic. What I would like to do is something like this - datum **myarray; /* datum is typedef'ed */ myarray = calloc(num_rows * num_cols, sizeof(datum)); The trouble is, what should I cast calloc to in order that I may address myarray using indices? I thought of doing something like this : myarray = (datum **) calloc ( ....) However, the datum that "myarray[i][j]" would address is not clear to me. The situation is even murkier when using higher dimensioned arrays. I would be very grateful for any ( and all ) answers. Please reply by mail, as I doubt greatly that this is of general interest. Regards, -- Binayak Banerjee {allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje P.S. Send Flames, I love mail.