On 3/28/07, Michael Reaves <[EMAIL PROTECTED]> wrote: > Group, > > I am trying to create a dynamic 2 dimensional array. I have to read in 2 > numbers from a file. These 2 numbers tell me what size array I need. How > do I take these 2 numbers and create a dynamic 2 dimensional array? For > example I read in 3 3 and need an array of points[3][3]. In the same file > later I read in 4 4 and need the same array points[4][4]. All suggestions > will be appreciated. >
C or C++? In C you will need to allocate memory: int *points = malloc (dim1 * dim2 * sizeof (int)); /* do stuff */ free (points); /* Don't forget to free the memory */ In C++ you have class vector that can handle the memory management for you. -- Tamas Marki
