I have a question on easy practices to read a settings.dat
file in a c++ software.
In my main c++ program, I declare global variables, read settings.dat
file for settings of my run and then do various things on many data files.
/************************************/
/** now program.cpp *****************/
/************************************/
int show-warnings;
int indent-spaces;
// global variables
void readSettings()
{
ifstream inputFile ("settings.dat");
inputFile >> show-warnings;
inputFile >> indent-spaces;
inputFile.close();
}
int main(int argc, char *argv[])
{
readSettings();
// do various things
return 0;
}
/************************************/
/** now: settings.dat ***************/
/************************************/
3
1
2
These settings are not labelled. Every time I change the settings, it's more difficult for me to remember what order these things are for.
This is what I'd like:
/************************************/
/** i'd like settings.dat ***********/
/************************************/
indent-spaces: 3
show-warnings: yes
purpose: update
I'm trying to make my settings.dat file more meaningful by (1) adding what each parameter is, followed by a colon, and (2) change to not-just-integers argument
If I have 20 parameters, and not all arguments are specified each time in the data file, I'd like to assume default values.
Could somebody point me to an easy/robust way of managing variables for these parameters within my c++ software? I don't even know what terms to search for in Google.
By the way, I use Windows 7, MING++, direct compilation.