How can I declare a variable or array that contain a value which does not get destroyed when the program terminates in c or c++?
Asked
Active
Viewed 68 times
-2
-
4File I/O is what you are probably after – StoryTeller - Unslander Monica Dec 17 '19 at 11:09
-
see [data hibernation for some clues](https://en.wikipedia.org/wiki/Hibernation_(computing)) – Nikos M. Dec 17 '19 at 11:11
-
I think you should start with the Beginners section in [the book list](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Dec 17 '19 at 12:33
2 Answers
3
When the process terminates, the kernel releases the resources owned by it. If you want to keep data/information obtained during the runtime of the process, you can use a database or the file system.

Saucy Goat
- 1,587
- 1
- 11
- 32
-
-
Check this basic tutorial on File I/O: https://www.tutorialspoint.com/cprogramming/c_file_io.htm – Saucy Goat Dec 17 '19 at 11:15
0
if you want to keep data after your process terminates, try storing it in a file. check this for more: file handling in C++

Ismail El Moudni
- 622
- 2
- 9
- 19