Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!gargoyle!ihnp4!ihlpg!tainter From: tainter@ihlpg.ATT.COM (Tainter) Newsgroups: comp.lang.c Subject: Re: How are local vars allocated? Message-ID: <4378@ihlpg.ATT.COM> Date: Mon, 30-Nov-87 11:36:10 EST Article-I.D.: ihlpg.4378 Posted: Mon Nov 30 11:36:10 1987 Date-Received: Thu, 3-Dec-87 05:06:38 EST References: <9367@mimsy.UUCP> <1633@megatest.UUCP> <1987Nov27.014354.11406@sq.uucp> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 15 >But the value of "k" is NOT guaranteed to be retained from one iteration >to the next, and you must not assume it will be. If you want that, you >have to declare "k" in a larger scope including the for-header. And you can do this without getting k too far away, as so: { int k; /* a variable that lives for the life of this loop */ for (;;) { ... } } Why is this so unpopular? --j.a.tainter