www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to create an array with custom length?

reply Quantium <qchessv2 gmail.com> writes:
Code
     int n=0;
     readf(" %d", &n);
     int[n] m;
generated an error (DMD compiler):
Cannot read n at compile time.
How to create an array with custom length?
Mar 27 2020
parent Anonymouse <zorael gmail.com> writes:
On Friday, 27 March 2020 at 19:30:39 UTC, Quantium wrote:
 Code
     int n=0;
     readf(" %d", &n);
     int[n] m;
 generated an error (DMD compiler):
 Cannot read n at compile time.
 How to create an array with custom length?
The tour has a page for this: https://tour.dlang.org/tour/en/basics/arrays int n=0; readf(" %d", &n); int[] m = new int[n];
Mar 27 2020