Question:
C++ saving stored variables?
anonymous
2011-04-06 17:07:38 UTC
I noticed that when I ran my C++ program and inputed variable values with user input, and then closed the program it reset the values and they were all blank when I ran the program again, is there anyway to save these variables other than storing them on a file? I know I could just put the values on a text file and have the program read it but the whole idea of the program is to keep the values secret unless you know what to type, and I don't want to go through encrypting the files, any other solutions?
Four answers:
The Phlebob
2011-04-06 18:24:16 UTC
If you mean you want to save variables' last values in the program executable itself, no. That's not gonna happen. Programs start fresh each time they're run. They wouldn't work if they didn't start with known values every time. (This is also called initializing variables).



How about storing them in the Registry (assuming you have a Windows program)? Not as good as encryption, but if you do a good job of camouflaging the key name only a real hacker will be able to find the values.



Hope that helps.
green meklar
2011-04-06 17:56:03 UTC
In order for anything to persist between runs of the program, it has to be written somewhere outside the program's own memory. The usual way would be to write a file to the hard drive and then access that on each run. However, there are other techniques. You could for instance have a second program constantly running in the background that doesn't do anything but accept data from the main program and feed it back when requested to.
oops
2011-04-06 17:27:05 UTC
There are other options, but none of them are as easy as simply encrypting the data, and they all involve writing data to some kind of device, be it a file, or through a network.
?
2017-02-25 16:36:23 UTC
There are not many different suggestions because of the fact the variables in a software are saved interior the RAM, that's erased as quickly as your software stopped working to make room for the different strategies. you should apply the gadget registry, yet that remains available for shoppers to open and study. A greater complicated yet probable useful option could be to save the help on a distant server over the internet, yet this could be plenty tougher than making use of an encrypted report. your ultimate option is probable to apply encryption.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...