Subj : Re: Creating an array in a function To : borland.public.cpp.borlandcpp From : waking Date : Sun Jul 25 2004 09:18 am On Sat, 24 Jul 2004 20:56:29 -0400, user@domain.invalid wrote: >I have an application that creates an array in main() using a const >arraySize. I want to pass the array and arraySize to a function that >will create a two-subscripted array using the arraySize passed to the >function. Every method I've tried results in a message saying a constant >must be used in the array declaration. For any compiler which is topical in this newsgroup (BC++ up to 5.02) a static (automatic) array in the function must be given a constant value which is known at compile-time. Of course, you can always use the passed size to create the array dynamically using malloc or new. Some compilers currently support a language extension which will allow local automatic arrays to be given a run-time size. Apparently the C99 Standard allows this as well, so as C compilers implement that feature it will become more widely available. See the C FAQ at http://www.eskimo.com/~scs/C-faq/faq.html especially 6.15: How can I declare local arrays of a size matching a passed-in array? 6.16: How can I dynamically allocate a multidimensional array? -- Wayne A. King (waking@idirect.com, Wayne_A_King@compuserve.com) .