473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

what are void,null and dangling pointers?

1.when referenced pointer is not active then it is called dangling pointer.
is this correct ?


2.the pointer which does not point to anything is called null pointer.

is NULL macro is a value for null pointer?

3.then what is void pointer?

i am not able to get differences between these three.please anyone help me.
Jul 4 '07 #1
3 3639
mohsin
19
1.when referenced pointer is not active then it is called dangling pointer.
is this correct ?


2.the pointer which does not point to anything is called null pointer.

is NULL macro is a value for null pointer?

3.then what is void pointer?

i am not able to get differences between these three.please anyone help me.

yes thats right "a pointer which does not point to anything is called null pointer"
secondly if more than one pointer pointing to one memory location and you delete one of these pointers then other pointing pointing to a memory which does not exist.this is called dangling pointer
Jul 4 '07 #2
drhowarddrfine
7,435 Expert 4TB
A void pointer can be thought of as a general purpose pointer that has not been assigned to point to a particular type of data. It is used to create a pointer that will later be cast to point at a defined type.
Jul 5 '07 #3
Avi23
7
Hi

Dangling Pointer is a pointer which is pointing to such memory blaock which has been deleted.
And a Null Pointer is one which to pointing no where.

e.g. int *ptr = new (int);
delete ptr; // now ptr will be a dangling pointer which is pointing to location that has been deleted.

ptr = NULL; // this makes the "ptr" to be a NULL pointer

Void Pointer:
its a pointer of geneneralized type.In other words we can say its a pointer that can be cast to desirable type.
Jul 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Aravind | last post by:
I would like to know in what manner dangling pointers affect the security of a application developed using C++.What are the loopholes that are created by dangling pointers and how they could be...
11
by: John | last post by:
Hi: Below is a simple code: class link1 { public: link1(); link1(int &b1, double &b2); int* a1;
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
16
by: Abhishek | last post by:
why do I see that in most C programs, pointers in functions are accepted as: int func(int i,(void *)p) where p is a pointer or an address which is passed from the place where it is called. what...
21
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no...
12
by: Michael Bell | last post by:
I am trying to put my learning effort into the most useful things. What do pointers do that other things can't? Michael Bell --
1
by: sridhard2406 | last post by:
Hi All, I have a doubt on undrestanding Dangling pointers.Below I mentioned sample code. please let me know, my view on Dangling pointers is correct or not? main( ) ...
20
by: prashant.khade1623 | last post by:
I am not getting the exact idea. Can you please explain me with an example. Thanks
16
by: John Doe | last post by:
Hi, I wrote a small class to enumerate available networks on a smartphone : class CNetwork { public: CNetwork() {}; CNetwork(CString& netName, GUID netguid): _netname(netName),...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.