On Wed, 2002-10-23 at 15:59, Aaron Ardiri wrote:
> > From: "Aaron Ardiri" <[EMAIL PROTECTED]>
> > >
> > > while, we are on the subject :P lets summarize :)
> > >
> > > str[index] = 0;
> > > str[index] = '\0';
> > > str[index] = NUL;
> >
> > Did you try to compile that?
>
> sure..
>
> ===
> #define NUL 0
>
> int main()
> {
> char str[255] = {};
> int index;
>
> index = 0;
> str[index] = 0;
> str[index] = '\0';
> str[index] = NUL;
>
> printf(str);
> }
> ===
>
> :) now, it compiles. NULL = (void *), which, is still zero by default.
> but, it is always better to declare your own NUL char :) it should be
> in the headers *g*
You've got two smilies and a grin here, so you're probably just joking
abotu the whole thing, but still...
While this would certainly work, it's the first time I've seen this idea
used this way, and my intuition rings alarm bells.
Would NUL match against type restrictions that expect a (void *)NULL?
Maybe or maybe not depending on the compiler, but why be ambiguous at
all?
When you're talking about trailing spaces at the end of a string, why
not *always* type:
str[index] = '\0';
If you're talking about integers, why not always:
myInts[index] = 0;
Every C programmer will have seen, dealt with, and learned what these
lines mean. Which means no ambiguities and hopefully fewer bugs.
-Ken
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/