what is stack and how to we use it. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is stack and how to we use it.

2nd Sep 2016, 5:46 PM
Kandarp Singh
Kandarp Singh - avatar
4 Answers
+ 3
The stack is where your local variables are allocated in memory.
2nd Sep 2016, 5:52 PM
Zen
Zen - avatar
+ 3
A stack isn't a physical object you can create. We can't really provide an example for it. int main() { int x = 5; } Here we are allocating memory from the stack to int x. If we were working with dynamic variables, that would be memory taken from the heap.
2nd Sep 2016, 6:01 PM
Cohen Creber
Cohen Creber - avatar
+ 2
cohen creber thanks for the reply
2nd Sep 2016, 6:07 PM
Kandarp Singh
Kandarp Singh - avatar
+ 1
but how to define a stqck please help wirh a function
2nd Sep 2016, 5:57 PM
Kandarp Singh
Kandarp Singh - avatar