Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making variables persist even after program termination

Tags:

c++

persist

I would like to have a variable to persist even after program termination. In other words, I'd like for a variable to remain in the memory even after an application exits from the main function. So, if my application is launched again, it could access that variable directly from the memory. Is this even possible? Would dynamic allocation, e.g. array=new int[size], do the trick?

like image 736
Alexey Avatar asked Feb 20 '23 17:02

Alexey


1 Answers

No, all memory is reclaimed by the os on process termination. You have to save stuff you want to a file.

like image 190
yuri kilochek Avatar answered Mar 03 '23 15:03

yuri kilochek