Declaration within a loop.
Peter Lim
plim at hpsgpa.HP.COM
Thu Sep 28 17:58:53 AEST 1989
/ hpsgpa:comp.lang.c / tim at 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.
More information about the Comp.lang.c
mailing list