Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Dynamic Arrays | Dynamic Memory
C++ Intermediate | Mobile-Friendly

bookDynamic Arrays

You can also allocate memory in RAM for arrays, which are called dynamic!

To create a dynamic array, just specify the type and number of elements you want in square brackets by declaring:

x = new int[5]; // Request memory
delete []x;    // Delete array pointed to x

Dynamic memory is extremely useful in many situations when your program doesn’t know how much place it needs. For instance, when your code needs to read a file or you want to create an array depending on user input.

question-icon

Fill gaps to create a string 4-element dynamic array a.

;
delete []a;

Click or drag`n`drop items and fill in the blanks

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 6

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Awesome!

Completion rate improved to 2.94

bookDynamic Arrays

Swipe um das Menü anzuzeigen

You can also allocate memory in RAM for arrays, which are called dynamic!

To create a dynamic array, just specify the type and number of elements you want in square brackets by declaring:

x = new int[5]; // Request memory
delete []x;    // Delete array pointed to x

Dynamic memory is extremely useful in many situations when your program doesn’t know how much place it needs. For instance, when your code needs to read a file or you want to create an array depending on user input.

question-icon

Fill gaps to create a string 4-element dynamic array a.

;
delete []a;

Click or drag`n`drop items and fill in the blanks

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 6
some-alt