+ 1
what is usefull of pointer?what is it practical application?
3 Answers
+ 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.
+ 1
thanks
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.