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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Dangling, Void , Null and Wild Pointers
- What is Memory Leak? How can we avoid?
- How many levels of pointers can we have in C/C++
- Why we should avoid using std::endl
- How to avoid Structure Padding in C?
- Memory leak in C++ and How to avoid it?
- Why C treats array parameters as pointers?
- Declare a C/C++ function returning pointer to array of integer pointers
- Introduction of Smart Pointers in C++ and It's Types
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Pointers in C/C++ with Examples
- Pointers vs References in C++
- What are near, far and huge pointers?
- Computing index using pointers returned by STL functions in C++
- The length of a string using pointers
- Applications of Pointers in C/C++
- Program to Reverse a String using Pointers
- Difference between pointer to an array and array of pointers
- C program to sort an array using pointers
- Features and Use of Pointers in C/C++
Improved By : guruvishnu_desireddy