Is there any way to store variables in a file, so that the program does not have to ask the user for imput that will never change over and over again.
EX: storing a name string forever in a file.
Thanks
Is there any way to store variables in a file, so that the program does not have to ask the user for imput that will never change over and over again.
EX: storing a name string forever in a file.
Thanks
Yes, do you mean like settings?
If so then you should look at ini or 'conifg' files. There are a few C++ ini classes on the interzweb, that could mean your file looks like:
And then,Code:[settings] name="Some string"
Or somethingCode:string name = iniClass.read("somefile.ini", "settings", "name");
Or just write the name to a file, and read the file to get the name (no formatting, just a name in a file).
Last edited by zacs7; 11-04-2007 at 07:21 PM.
If it's the same every time you run the program, then store it in the program itself.
Otherwise, to store it in a file just use fstreams. Use an ofstream to write it out when you get it, and an ifstream to read it in when you need it.
That's a big topic for a simple post. There is a tutorial on fstreams on the main site, and it should also be explained in detail in your book.