How not to destroy a variable when exiting a function? (not static) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How not to destroy a variable when exiting a function? (not static)

For example: int spam(void){ int a[16]; return 42; } How to keep the `a' array undestroyed, but while each time the function is called, there get greated "a new array of size 16"?

23rd Oct 2020, 5:27 PM
Gwlanbzh
Gwlanbzh - avatar
1 Answer
0
A non static variable is never destroyed until program execution finished.
24th Oct 2020, 1:37 AM
Aditya rout
Aditya rout - avatar