> while (*T++=*S++);
> do
> {
> X = *S;
> *T = X;
> S++;
> T++;
> }
> while('\0' != X);
(obvious fix applied to the condition)
The long version isn't less efficient.
Actually, it is, or at least may be, depending on the compiler; there
certainly are semantic differences between them.
In particular, in the original, there is no sequence point during the
load-store-increment-increment operation, which means the compiler can
make assumptions like "neither T nor S points into either T or S" and
let the undefined behaviour resulting from multiple modifications
between sequence points cover for it if they do. The long version has
sequence points all through it, and, for example, the compiler cannot
assume that T does not point into S and thus S++ cannot be collapsed
with *S.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse at
rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B