What is the stack in C?
Submitted by: AdministratorThe stack is where all the functions' local (auto) variables are created. The stack also contains some information used to call and return from functions.
A stack trace is a list of which functions have been called, based on this information. When you start using a debugger, one of the first things you should learn is how to get a stack trace.
The stack is very inflexible about allocating memory; everything must be deallocated in exactly the reverse order it was allocated in. For implementing function calls, that is all that's needed. Allocating memory off the stack is extremely efficient. One of the reasons C compilers generate such good code is their heavy use of a simple stack.
There used to be a C function that any programmer could use for allocating memory off the stack. The memory was automatically deallocated when the calling function returned. This was a dangerous function to call; it's not available anymore.
Submitted by: Administrator
A stack trace is a list of which functions have been called, based on this information. When you start using a debugger, one of the first things you should learn is how to get a stack trace.
The stack is very inflexible about allocating memory; everything must be deallocated in exactly the reverse order it was allocated in. For implementing function calls, that is all that's needed. Allocating memory off the stack is extremely efficient. One of the reasons C compilers generate such good code is their heavy use of a simple stack.
There used to be a C function that any programmer could use for allocating memory off the stack. The memory was automatically deallocated when the calling function returned. This was a dangerous function to call; it's not available anymore.
Submitted by: Administrator
Read Online C Programming Job Interview Questions And Answers
Top C Programming Questions
| ☺ | Why does this code crash? |
| ☺ | What is wrong with this declaration? |
| ☺ | How can I read/write structures from/to data files? |
| ☺ | What does static variable mean in c? |
| ☺ | How can I increase the allowable number of simultaneously open files? |
Top Coding/Programming Categories
| ☺ | Python Interview Questions. |
| ☺ | OOP Interview Questions. |
| ☺ | Software engineering Interview Questions. |
| ☺ | PHP Interview Questions. |
| ☺ | VBA (Visual Basic for Applications) Interview Questions. |
