Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!bloom-beacon!oberon!cit-vax!tybalt.caltech.edu!janin From: janin@tybalt.caltech.edu (Adam L. Janin) Newsgroups: comp.sys.mac.programmer Subject: use of alloca Message-ID: <8264@cit-vax.Caltech.Edu> Date: 10 Oct 88 04:04:04 GMT Sender: news@cit-vax.Caltech.Edu Reply-To: janin@tybalt.caltech.edu (Adam L. Janin) Organization: California Institute of Technology Lines: 20 Thanks to everyone who sent replies about Bison! There is a much easier way to allocate stuff on the stack in C than using alloca. Variable declarations can be put after ANY open brace. The scope of the variable is local to the set of braces. For example: for (a = 0; a < 10; a++) { int x; ... printf("%d", x); /* Works correctly */ ... } printf("%d", x); /* Does not work. Variable not defined here. */ etc. Although this works, it is sometimes difficult to read code that contains statements like this, since it can be hard to find the variable declarations. Adam Janin janin@tybalt.caltech.edu or janin@csvax.caltech.edu