+ 2

How to deal with arrays with unknown length?

I want to make a function that stores the divisors of a number in an array, and that number is given by the user, so i don't know how many divisors there are going to be and therefore i don't know what is the size of the array, it could be small so i don't want to reserve memory not needed

18th Feb 2018, 7:53 PM
Anas Alrayes
Anas Alrayes - avatar
3 Answers
18th Feb 2018, 8:35 PM
Alex
Alex - avatar
0
well I am no c++ specialist. but with 'new' you allocate new memory from heap
18th Feb 2018, 8:23 PM
Merlin Mittelbach