497 views

1 Answer

Best answer
1 votes
1 votes

After freeing up a pointer variable if we are trying to de reference that, it gives error based on the platform. Suppose we have a code snippet like this:

int a=10,*p;

p = &a;

free(p);

*p = 20;

p is a dangling pointer right.

Now this code can primarily give two kinds of error but the kind of error depends totally on the platform and implementation.(Both the errors mentioned refers to the same Error Type. The error names are different based on the platform/implementation).

  1. In case of UNIX based it will give Segmentation Fault( Core Dumped).
  2. For rest of them it usually gives ILLEGAL MEMORY ACCESS.

Again the error is totally dependent on the platform.

edited by

Related questions

1 votes
1 votes
1 answer
3