+ 2

Dynamic allocation basic(help)

what is benefit of dynamic allocation on this code.I can get user input at run time and print the output.in this program whether memory is deleted or not after close the program . https://code.sololearn.com/ctteq9dGFx3n/?ref=app

24th May 2018, 4:11 AM
Bahubali
Bahubali - avatar
2 Answers
+ 7
Note that some compilers do not allow variables in place of array size for array declaration. int a[n]; Instead: int* a = new int[n]; is universally accepted.
24th May 2018, 5:22 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Dynamic allocation, for this kind of code, is great when you dont know how many elements the user wants to input.
24th May 2018, 5:04 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar