

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are Wild Pointers in C/C++?
Pointers store the memory addresses. Wild pointers are different from pointers i.e. they also store the memory addresses but point the unallocated memory or data value which has been deallocated. Such pointers are known as wild pointers.
A pointer behaves like a wild pointer when it is declared but not initialized. That is why, they point any random memory location.
Here is an example of wild pointers in C++ language,
Example
#include <bits/stdc++.h> using namespace std; int main() { int *arr; for(int i=0; i<5 ; i++) cout << arr[i] << " "; return 0; }
Output
1 0 -426634956 32764 0
In the above program, a pointer arr is declared but not initialized. So, it is displaying some random memory locations.
int *arr; for(int i=0; i<5 ; i++) cout << arr[i] << " ";
- Related Questions & Answers
- Dangling, Void, Null and Wild Pointers in C++
- Dangling, Void, Null and Wild Pointers in C/C++
- What are pointers in C#?
- What are pointers to structures in C language?
- What are the famous Wild Life Sanctuaries in India?
- What are the different types of pointers in C language?
- Pointers, smart pointers and shared pointers in C++
- Pointers in C/C++
- What are different pointer operations and problems with pointers in C language?
- Why are NULL pointers defined differently in C and C++?
- Applications of Pointers in C/C++
- Pointers vs References in C++
- How to compare pointers in C/C++?
- C/C++ Pointers vs Java references
- RAII and smart pointers in C++
Advertisements