On Tue, Jun 25, 2002 at 12:53:03PM -0700, Craig Belson wrote:
> >
> > > First see if the pointer is not NULL (there is a
> > pointer), then, if there
> > is a pointer, see if there is a
> > > character in there (it's actually pointing at a
> > string).
> So in other words, check to see that there's a Char*
> tempcharstar; somewhere above this, and then if there
> is, check if there's something in there? (Like I said,
> I was never very good w/ pointers *g*)
you should simply check that the pointer is not NULL
(btw Char *tempcharstar continues to be a pointer also
when its values is NULL).
> >
> > StrCopy(string, tempcharstar ? tempcharstar : "");
> >
> I'm familiar w/ ternarys like that - or at least I
> think that's the fancy name for if statements *s* -
> but I try to stay away from them b/c if I don't
> program for a while, then go back and look at it, I'd
> rather be able to see exactly what I was trying to say
> rather than have to decipher it. :-)
it's not the same thing: the ternary operator is
an "expression", while the regular `if' is a
"statement".
These two snippets are equivalent:
if (tempcharstar)
StrCopy(string, tempcharstar);
else
StrCopy(string, "");
and
StrCopy(string, tempcharstar ? tempcharstar : "");
(FWIW I'm slightly partial to the latter, since it's more concise
and, at least in my opinion, clearer).
Marco
--
========================================================================
Marco Pantaleoni [EMAIL PROTECTED]
Padova, Italy [EMAIL PROTECTED]
elastiC language developer http://www.elasticworld.org
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/