On Friday, 24 July 2015 at 15:26:27 UTC, Adam D. Ruppe wrote:
On Friday, 24 July 2015 at 15:22:15 UTC, Binarydepth wrote:
I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input.

Declare:

int[2][] your_array;

your_array.length = var;


The runtime will handle the dynamic memory allocation for you when you set the length on a slice.

this is what I did :

int liCases [2][];
        readf(" %d\n", &num);//Number of cases input
        liCases.length = num;

And I get this error :

prime1.d:26: error: constant liCases.length is not an lvalue
  • Dynamic memory Binarydepth via Digitalmars-d-learn
    • Re: Dynamic memory Adam D. Ruppe via Digitalmars-d-learn
      • Re: Dynamic memory Binarydepth via Digitalmars-d-learn
        • Re: Dynamic memo... Adam D. Ruppe via Digitalmars-d-learn
          • Re: Dynamic ... Binarydepth via Digitalmars-d-learn
            • Re: Dyn... Adam D. Ruppe via Digitalmars-d-learn
              • Re:... Binarydepth via Digitalmars-d-learn
            • Re: Dyn... anonymous via Digitalmars-d-learn
              • Re:... Binarydepth via Digitalmars-d-learn
              • Re:... Binarydepth via Digitalmars-d-learn
                • ... anonymous via Digitalmars-d-learn
                • ... Binarydepth via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn

Reply via email to