With the help of a suitable program discuss pointers can be helpful in programming | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

With the help of a suitable program discuss pointers can be helpful in programming

29th Mar 2020, 1:35 PM
Brian Bor
3 Antworten
0
It can be usefull storing the memory address of variables because you get access to the heap memory, you can avoid copying values(which can take a lot of time) and you are also saving a lot of memory storage (considenring that memory is limited). For example lets say that you have an array of 1000 car objects (let's say that this object has a size of 100 bytes). But you want to make another array which stores only these cars that are grey(250 of these cars are actually grey). One solution would be to start copying everysingle one of these in a new array of 250 elements. That would not only take a long amount of time, but the size of the new array would be an extra 25KB. The other solution would be to store in an array pointers to each grey car. That would take far less time(copying just memory adresses) AND the size of the new array would only be 1KB (a pointer is an integer so it is 4bytes per pointer)!
29th Mar 2020, 2:33 PM
xaralampis_
xaralampis_ - avatar
0
Kindly write the program
29th Mar 2020, 6:09 PM
Brian Bor
0
Brian Bor, I just explained to you a common situation, why do you need the programm in order to understand?
29th Mar 2020, 7:54 PM
xaralampis_
xaralampis_ - avatar