Re: Finding invalid pointers
On 4 Feb, 18:57, TDB <vnrb...@gmail.com> wrote:
> int main() {
> void *p;
>
> p=(void *)0x00000005;
>
> // Here
> printf(" %d ",* (int *)p);
>
> return 0;
> }
>
> When I executed the above code using GCC and VC++, it caused
> segmentation error and windows error..
>
> I need a condition that can find whether the pointer address will
> cause error or not..
>
> Any suggestions to construct that condition ?
In my opinion, you are wrong to use the pointer in that way. If you've
declared p with void, but after you've used then it as an int.
|