Dynamic memory
Binarydepth via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 24 08:33:43 PDT 2015
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
More information about the Digitalmars-d-learn
mailing list