Re: questions about Eu and C

new topic     » goto parent     » topic index » view thread      » older message » newer message

I dont think you can allocate variable length arrays in C but in C++ the
'new' command works for that as well as other things too. The first
dimension must still be constant however.

C++ Example code:

  //dim1 and dim2 are dimensions of array
  //makes a dim1 x dim2 array of type 'char'

  char** lpArray;
  ulong jarray;
  ulong MakeArray(void)
    {
      lpArray=(char**)new ulong[dim1];
       for(jarray=0;jarray<dim1;jarray++)
           lpArray[jarray]=new char[dim2];
      return ulong(lpArray);
    }


  //cleanup:

  ulong DistroyArray(void)
    {
      for(jarray=0;jarray<dim1;jarray++)
          delete[](lpArray[jarray]);
      delete[]lpArray;
      return 1;
    }


--AL

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu