+ 2

dynamic memory allocation, cannot be performed without using pointers. how?why?

21st Feb 2019, 4:48 AM
Manav Malhotra
Manav Malhotra - avatar
2 Respostas
+ 2
Because when you get a variable, you only get the value, not the variable reference. So you can’t allocate memory to a number or whatever you’re trying to allocate to.
21st Feb 2019, 5:40 AM
Rowsej
Rowsej - avatar
+ 3
In dynamic memory allocation you request the computer for memory. The compiler goes and sees what memory it has available. Assuming it has enough to give us, the operating system Will set aside the amount of memory requested and give us that memory's address so that we can use it. How do we store an address ? In a pointer !! Hope it will help!!
21st Feb 2019, 7:11 AM
shalini jha
shalini jha - avatar