Path: utzoo!utgpu!news-server.csri.toronto.edu!qucdn!spraggej Organization: Queen's University at Kingston Date: Friday, 12 Apr 1991 21:43:00 EDT From: John G. Spragge Message-ID: <91102.214300SPRAGGEJ@QUCDN.QueensU.CA> Newsgroups: comp.lang.pascal Subject: Re: need dynamic array on heap References: <1991Apr12.234843.9031@ux1.cso.uiuc.edu> In article <1991Apr12.234843.9031@ux1.cso.uiuc.edu>, amead@s.psych.uiuc.edu (alan mead) says: > >I want to put aside a chunk of the heap and then index it by byte like >an array of byte. I could just declare it as some type like >'array[1..64000] of byte', but I want to use GetMem so that the array will >really be dynamic (I don't want to use 64K each time). > >So, I'm trying this: > >program Test; > type > C_arrayType = array[1..1] of byte; > var > Buff : ^C_arrayType; > begin > GetMem( Buff,1000 ); > Buff[1]^ := 2; > end. > >But I get > > Buff[1]^ := 2; > ^ Invalid qualifier > >so does anyone know, is this sort of thing possible? Can you do this >easily in C? You're putting the pointer in the wrong place. Buff is a pointer; what you're trying to say is (in English) reference the array pointed at by pointer variable BUFF at location (n), and assign the number 10. translated into Pascal, this becomes buff^ [1] := 10; Thus: buff (Pascal variable) = [o] | points at (buff^) V +------------------------------------ \ an array on the heap | | | | | | | | | | | | / +-------------------------------------\ 1 2 3 4 5 6 7 8 9 10 11 ^ | so that: buff^ [10] -----------------------------+ disclaimer: Queen's University supplies me with computer services, not my opinions. John G. Spragge