hi, im am wondering if the is a way to make a 2D array of variable length. I have tried making a variable and assigning it a value and then used that variable to define the size of the array, but i cannot seem to get that to work. Is this possible or is there a way around this? Or simply do i just have to make the array very large and hope it does not exceed this value.

you need to post some code that illustrates what you are trying to do. Newest c++ standards allow for creating arrays with variables, but some compilers may not support this. For example

int foo(int size)
{
   char array[size];
}

I have used the format that you have written it just seems that i will have to get a better compiler, thanks for the help

The alternative is to do it the old-fashioned way -- use malloc or new (depending on c or c++)

int foo(int size)
{
   char *array = new char[size];

  // blabla
  // now delete it
  delete[] array;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.