Re: Avoiding dereference of NULL pointer
On Sat, 15 Dec 2007 03:52:53 -0600, Tony Jackson wrote
(in article <slrnfm78vl.jk8 .nospam@nospam. invalid>):
Rule #1: Don't show the customer the program before it is finished.
This is almost certain to be a very poor belief to hold,
And this is probably not the right approach to handle it either.
- probably the next time round the loop the pointer will be OK.
Because of divine intervention?
Detect the error, and take appropriate action when it occurs.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
On Sat, 15 Dec 2007 03:52:53 -0600, Tony Jackson wrote
(in article <slrnfm78vl.jk8 .nospam@nospam. invalid>):
Hi
>
I'm quite new to C programming - I have more of a Java background: maybe
someone here can advise me.
>
I'm nearly finishing a little program but it has some hard-to-find bugs
that basically lead to a couple pointers sometimes being NULL at the
wrong time. As it stands the program just bombs out when it tries to
dereference the NULL, which obviously isn't good (especially when it
happens with the customer looking on!!).
>
I'm quite new to C programming - I have more of a Java background: maybe
someone here can advise me.
>
I'm nearly finishing a little program but it has some hard-to-find bugs
that basically lead to a couple pointers sometimes being NULL at the
wrong time. As it stands the program just bombs out when it tries to
dereference the NULL, which obviously isn't good (especially when it
happens with the customer looking on!!).
I don't think there's any serious problem to worry about,
This is almost certain to be a very poor belief to hold,
and what I'd
like to do is be able to ignore the dereference attempt and just carry
on
like to do is be able to ignore the dereference attempt and just carry
on
- probably the next time round the loop the pointer will be OK.
Because of divine intervention?
In
Java, I'd put a try block around the main loop, and if we catch an
exception then just jump back to the start of the main loop. What's the
corresponding thing in C?
Java, I'd put a try block around the main loop, and if we catch an
exception then just jump back to the start of the main loop. What's the
corresponding thing in C?
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
Comment