Comparing strings...

Tim McDaniel mcdaniel at adi.com
Thu Oct 18 01:04:07 AEST 1990


gordon at osiris.cso.uiuc.edu (John Gordon) writes:

> Also, one other thing: for() and while() loops are essentially
> identical.

"Essentially identical" is not identical to "identical".  As Dad says,
"'Close' only counts in horseshoes and hand grenades".

> The following loops are exactly the same:

Unless "continue" is used: in a "while" loop, control passes
immediately to the conditional expression, but in a "for" loop, the
third control expression is done before it goes to the conditional
expression.  So

   for (i = 0; i < 100; i++) {
      <code #1>
         continue;
      <code #2>
   }

is identical to

   i = 0;
   while (i < 100) {
      <code #1>
         goto uniqueLabel;
      <code #2>
   uniqueLabel:
      i++;
   }

To the best of my knowledge, they are otherwise identical.
--
Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Work phone: +1 313 973 1300                        Home phone: +1 313 677 4386
Internet: mcdaniel at adi.com                UUCP: {uunet,sharkey}!amara!mcdaniel



More information about the Comp.lang.c mailing list