QQ said:
what's the different between
TE==NULL and
*TE==0
if (TE == NULL) /* if TE points "to nowhere" */
if (*TE == 0) /* if the thing TE points to is 0 */
newbie example, trying to explain with a bit of fun mixed-in:
point your finger to any number (read vertically) in the list below.
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
.... Let's say you pointed to the number 18 and call your finger TE, so
*TE == 0 /* evaluates to false, because *TE == 18 */
TE == NULL /* evaluates to false, because TE is pointing to
somewhere relevant */
.... now cut your finger off (or, better, close your hand into a fist)
TE == NULL /* evaluates to true now; your finger isn't pointing to
anywhere */
/* *TE == 0 */ /* you can't do this now -- if the finger isn't
pointing to somewhere specific, you can't check
the value of what it points to */
.... now, assuming you opted to close your hand, point your finger to the
number 0 in the list
TE == NULL /* evaluates to false again */
*TE == 0 /* evaluates to true */
move your finger 26 positions to the right (TE = TE + 26
Q: where does it point to?
A: it points to somewhere outside the boundaries of the list and (if I
am not wrong) you have demons oozing out of your nostrils at this
moment