+ 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
3 Answers
+ 3
https://code.sololearn.com/c6kol3iqswUQ/?ref=app
https://code.sololearn.com/cuXW5p4b5MJ2/?ref=app
But for your problem I would use a vector
0
well I am no c++ specialist. but with 'new' you allocate new memory from heap