Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpda!hpcuhc!hpcupt3!defaria From: defaria@hpcupt3.cup.hp.com (Andy DeFaria) Newsgroups: comp.lang.pascal Subject: Re: need dynamic array on heap Message-ID: <45670011@hpcupt3.cup.hp.com> Date: 15 Apr 91 16:59:45 GMT References: <1991Apr12.234843.9031@ux1.cso.uiuc.edu> Organization: Hewlett Packard, Cupertino Lines: 34 >/ hpcupt3:comp.lang.pascal / amead@s.psych.uiuc.edu (alan mead) / 3:48 pm Apr 12, 1991 / >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? Change the TYPE to type C_arrayType = array[1..64000] of byte; After all a type doesn't allocate any memory, it is the getmem that will allocate the memory on the heap. When you say Buff[1] TP knows that they array only goes 1..1 so you get a compiler error.