Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!uxc!uxc.cso.uiuc.edu!uxg.cso.uiuc.edu!uxe.cso.uiuc.edu!mcdonald From: mcdonald@uxe.cso.uiuc.edu Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical anal Message-ID: <50500075@uxe.cso.uiuc.edu> Date: 16 Sep 88 13:53:00 GMT References: <893@amelia.nas.nasa.gov> Lines: 69 Nf-ID: #R:amelia.nas.nasa.gov:893:uxe.cso.uiuc.edu:50500075:000:1775 Nf-From: uxe.cso.uiuc.edu!mcdonald Sep 16 08:53:00 1988 From article <1511@ficc.uu.net>, by peter@ficc.uu.net (Peter da Silva): > (*twodarray)[10][5] = 'c'; > > Now you have. Reply by J. Giles: >Gee, that looks like and array of pointers to me. If there's no pointers >involved, what's that asterisk doing there? This is certainly _not_ >an example of a 2-d array that is done without an array of pointers. I tried to do this yesterday, but failed due to not getting the parenthesis right. But Peter's example does indeed work, to wit on my PC (microsoft 5.1): main() { char (*twodarray)[10][10]; int i; twodarray = malloc(sizeof(*twodarray)); for(i = 0; i < 10; i++) (*twodarray)[i][3] = i; } _main PROC NEAR push bp mov bp,sp mov ax,4 call __chkstk push si ; twodarray = -4 ; i = -2 ; Line 4 mov ax,100 push ax call _malloc add sp,2 mov WORD PTR [bp-4],ax ;twodarray ; Line 6 mov WORD PTR [bp-2],0 ;i $FC106: ; Line 7 mov si,WORD PTR [bp-2] ;i mov ax,si shl si,1 shl si,1 add si,ax shl si,1 mov bx,WORD PTR [bp-4] ;twodarray mov al,BYTE PTR [bp-2] ;i mov [bx+3][si],al inc WORD PTR [bp-2] ;i cmp WORD PTR [bp-2],10 ;i jl $FC106 ; Line 8 pop si mov sp,bp pop bp ret _main ENDP Sure looks like array indexing calculations to me. Of course, for this example pointer tricks could be faster. Now if those two array sizes could be VARIABLES ........ Why not add this, even at this late date? Unnecessary but convenient. Doug McDonald