new do-while syntax

William C. DenBesten denbeste at bgsuvax.UUCP
Fri Dec 23 06:05:25 AEST 1988


How 'bout something simple that works _now_?

#define loop for(;;)
#define exitif(a) if (a) break

main()
{
  char ch;
  loop {
    ch = getchar();
    exitif (ch==EOF);
    putc(ch);
  }
}

This seems much less prone to a missing semi-colon causing a really nasty
error. IMHO, this is much easier to follow than do{}while(){};.

-- 
          William C. DenBesten |       denbeste at bgsu.edu
      Dept of Computer Science | CSNET denbeste%andy.bgsu.edu at relay.cs.net
Bowling Green State University | UUCP  ...!osu-cis!bgsuvax!denbeste
  Bowling Green, OH 43403-0214 |



More information about the Comp.lang.c mailing list