470,856 Members | 2,508 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,856 developers. It's quick & easy.

doubt on Dangling pointer

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( )
char *a,*b,*c;

a = (char *)malloc(40);
b = a;
c = b;
/* now c is Dangling pointer*/
is it vorrect? if not please let know with Example program ?

Feb 15 '08 #1
1 2223
9,208 Expert Mod 8TB
Yep. b is dangling also.

This is why there is grave danger in passing naked pointers throughout your code: You don't know when it's safe to free().
Feb 15 '08 #2

Post your reply

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

Similar topics

13 posts views Thread by Aravind | last post: by
11 posts views Thread by John | last post: by
20 posts views Thread by __PPS__ | last post: by
138 posts views Thread by ambika | last post: by
5 posts views Thread by Richard | last post: by
1 post views Thread by sekhar_ps | last post: by
3 posts views Thread by gsuresh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.