2 votes 2 votes void main() { int *ptr; ..... ..... { int ch; ptr = &ch; } ..... // Here ptr is dangling pointer } Since here's no function calling and only main(). So, I am not able to understand which variable is going out of scope? ptr or ch? Thanks all! Programming in C programming-in-c pointers + – iarnav asked May 5, 2017 iarnav 314 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Ptr have an invalid memory address because variable ch scope not after the inner block You should click on this link http://googleweblight.com/i?u=http://www.c4learn.com/c-programming/c-dangling-pointer-causes/&grqid=540NqNjp&hl=en-IN Nitesh Choudhary answered May 5, 2017 Nitesh Choudhary comment Share Follow See 1 comment See all 1 1 comment reply iarnav commented May 6, 2017 reply Follow Share thanks! 0 votes 0 votes Please log in or register to add a comment.