Re: function explanation
On Fri, 26 Sep 2003, CBFalconer wrote:
[color=blue][color=green][color=darkred]
> > > What is difficult to understand about...?
> > >
> > > while (*s++ = *t++)
> > > ;[/color]
> >
> > First, there's an off by one error. Second, it doesn't terminate
> > the destination string.[/color]
>
> No there isn't (an error). Yes it does (terminate).[/color]
And that's supposed to be easy to understand?
*t++; /* "get()" */
*s++=x; /* "put(x)" */
*s++=*t++; /* "put(get()) " */
while (tmp=*t++) *s++=tmp;
/* "as long as we can get data, append it to s" */
*s=0;
/* terminate s; */
while (*t) *s++=*t++;
*s=0;
/* "as long as there's data, copy it." */
while (*s++=*t++) ;
/* "as long as we have copied nonzero data, do nothing. perform extra
copy as a side effect of embedding it in the test" */
(of course if you interpret "*s++=*t++" as a routine which returns 0
when it has finished it makes a whole lot more sense..)
On Fri, 26 Sep 2003, CBFalconer wrote:
[color=blue][color=green][color=darkred]
> > > What is difficult to understand about...?
> > >
> > > while (*s++ = *t++)
> > > ;[/color]
> >
> > First, there's an off by one error. Second, it doesn't terminate
> > the destination string.[/color]
>
> No there isn't (an error). Yes it does (terminate).[/color]
And that's supposed to be easy to understand?
*t++; /* "get()" */
*s++=x; /* "put(x)" */
*s++=*t++; /* "put(get()) " */
while (tmp=*t++) *s++=tmp;
/* "as long as we can get data, append it to s" */
*s=0;
/* terminate s; */
while (*t) *s++=*t++;
*s=0;
/* "as long as there's data, copy it." */
while (*s++=*t++) ;
/* "as long as we have copied nonzero data, do nothing. perform extra
copy as a side effect of embedding it in the test" */
(of course if you interpret "*s++=*t++" as a routine which returns 0
when it has finished it makes a whole lot more sense..)
Comment