Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!apple!oliveb!pyramid!prls!philabs!linus!bs From: bs@linus.UUCP (Robert D. Silverman) Newsgroups: comp.lang.c Subject: Re: C Message-ID: <45510@linus.UUCP> Date: 28 Feb 89 14:24:16 GMT References: <1256@dukeac.UUCP> <9743@smoke.BRL.MIL> <9501@bloom-beacon.MIT.EDU> Reply-To: bs@linus.UUCP (Robert D. Silverman) Organization: The MITRE Corporation, Bedford MA Lines: 24 In article <9501@bloom-beacon.MIT.EDU> yphotons@athena.mit.edu (Sun Warrior) writes: : :I would like to know how to set an array (float) to a certain size :normally I would have done it like this : :float array [size] : :but the thing is I would first like to be able to type in the size and :then set the array . I tried this by using scanf statement and then :the float but that did not work. help : :yphotons@athena.mit.edu This is rather easy. Declare 'array' to be a pointer to a float, then call malloc to allocate the memory space. e.g. float *array array = (float*) malloc(size* sizeof(float)); etc. Bob Silverman