Uninitialized pointers are known as wild pointers because they point to some arbitrary memory location and may cause a program to crash or behave badly.
Please note that if a pointer p points to a known variable then it’s not a wild pointer. In the below program, p is a wild pointer till this points to a.
If we want pointer to a value (or set of values) without having a variable for the value, we should explicitly allocate memory and put the value in allocated memory.
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.
- Dangling, Void , Null and Wild Pointers
- Why we should avoid using std::endl
- What is Memory Leak? How can we avoid?
- Memory leak in C++ and How to avoid it?
- How to avoid Structure Padding in C?
- Pointers and References in C++
- Features and Use of Pointers in C/C++
- Applications of Pointers in C/C++
- How many levels of pointers can we have in C/C++
- Pointers vs References in C++
- What are near, far and huge pointers?
- Pointers in C/C++ with Examples
- The length of a string using pointers
- Chain of Pointers in C with Examples
- Why do we need reference variables if we have pointers
- Difference between Iterators and Pointers in C/C++ with Examples
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Program to Reverse a String using Pointers
- Introduction of Smart Pointers in C++ and It's Types
- Why C treats array parameters as pointers?
Improved By : guruvishnu_desireddy