Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-pcd!hpsgpa!plim
From: plim@hpsgpa.HP.COM (Peter Lim)
Newsgroups: comp.lang.c
Subject: Re: Declaration within a loop.
Message-ID: <2430001@hpsgpa.HP.COM>
Date: 28 Sep 89 07:58:53 GMT
References: <2085@hydra.gatech.EDU>
Organization: HP Singapore IC Design Ctr
Lines: 28

/ hpsgpa:comp.lang.c / tim@cayman.amd.com (Tim Olson) /  3:11 am  Sep 28, 1989 /

> But sometimes it is better to declare the variable in the block to
> limit its scope rather than to make every variable visible to the
> entire function.  For example, say I want to debug a function by
> printing out a linked list at a certain point.  I can say something
> like:
> 

Well, why don't you do something like adding an extra pair of braces
before and after the loop like:

  {
  int i;
     do {
       .
       .
     } while (1);
  }

this should limit the scope of i in the loop and clear the ambiguity
of whether i is re-allocated every time round the loop.
** Seem obvious to me.


Regards,
Peter Lim.
HP Singapore IC Design Center.