what is usefull of pointer?what is it practical application? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

what is usefull of pointer?what is it practical application?

25th Jan 2018, 5:59 AM
SOUVIK RAY BARMAN
SOUVIK RAY BARMAN - avatar
3 Antworten
+ 1
A pointer is a way to refer to a specific memory location. You can use pointers for moving references to variables around instead of copying them. Also, the array syntax in C and C++ basically translates to direct pointer access. arr[1] is the same as *(&arr + 1). Pointers are also useful for allocating, reallocation and freeing memory blocks, and a bunch of other stuff like lists and collections.
25th Jan 2018, 6:52 AM
SplittyDev
SplittyDev - avatar
+ 1
thanks
25th Jan 2018, 8:47 AM
SOUVIK RAY BARMAN
SOUVIK RAY BARMAN - avatar
0
The most obvious application is arrays. You define a pointer to the first element of the array and allocate n*i bytes in that physical location, where n is the number of elements, and i the size of each element. Another application is a list in which is element also contains a pointer to the next element. You can also pass them to function to have them modify the original value.
25th Jan 2018, 6:28 AM
Vlad Serbu
Vlad Serbu - avatar