TDB 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 ?
Peek/poke games require either having access to a memory map,
hooks into the OS (for dynamically-allocated areas), or some way
to intercept the segmentation error and render it non-fatal.
If you don't have one of those three facilities, then you're
stuck with the existing mechanism that detects the invalid access
and terminates the program.
FYI *p == 0xC3 on all CP/M systems. :-)
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto