Are auto variables stored in the stack?

May 5, 2011 at 4:33am
My last C++ class test had a question which read "Write an example of using memory on the stack" or something along those lines. I didn't know any way to use the stack other than passing function parameters and return values. I explained this in writing and got credit, but I'm still wondering how the question was meant to be answered. Are local variables (default or with the auto keyword) stored on the stack? If not, are there variable types that are stored on the stack?
Thanks!
May 5, 2011 at 5:59am
Yes local variables (aka automatic variables that disappear when they fall out of scope) are stored on the stack, along with function parameters and return values.
May 5, 2011 at 4:41pm
Great, thanks!
Topic archived. No new replies allowed.