Pointers store address of variables or a memory location.
Example: pointer “ptr” holds address of an integer variable or holds address of a memory whose value(s) can be accessed as integer values through “ptr”
Features of Pointers:
- Pointers save memory space.
- Execution time with pointers is faster because data are manipulated with the address, that is, direct access to
- Memory is accessed efficiently with the pointers. The pointer assigns and releases the memory as well. Hence it can be said the Memory of pointers is dynamically allocated.
- Pointers are used with data structures. They are useful for representing two-dimensional and multi-dimensional
- An array, of any type can be accessed with the help of pointers, without considering its subscript range.
- Pointers are used for file handling.
- Pointers are used to allocate memory dynamically.
- In C++, a pointer declared to a base class could access the object of a derived class. However, a pointer to a derived class cannot access the object of a base class.
Uses of pointers:
- To pass arguments by reference
- For accessing array elements
- To return multiple values
- Dynamic memory allocation
- To implement data structures
- To do system level programming where memory addresses are useful
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Features of C Programming Language
- Train a Support Vector Machine to recognize facial features in C++
- Pointers and References in C++
- What are near, far and huge pointers?
- Pointers vs References in C++
- Pointers in C/C++ with Examples
- How many levels of pointers can we have in C/C++
- Applications of Pointers in C/C++
- Chain of Pointers in C with Examples
- What are Wild Pointers? How can we avoid?
- Output of C programs | Set 64 (Pointers)
- The length of a string using pointers
- Why do we need reference variables if we have pointers
- Difference between Iterators and Pointers in C/C++ with Examples
- Why C treats array parameters as pointers?
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Check if a string is palindrome in C using pointers
- Program to Reverse a String using Pointers
- C++ Program to compare two string using pointers
- Introduction of Smart Pointers in C++ and It's Types
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.