Search code examples
c++persist

Making variables persist even after program termination


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?


Solution

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