No. It's just a text file... say you have a text file called settings.txt which has the details you want in it. Read in the values from that and use them in your program. I do it via something like:
bool readSettings( std::map<std::string,std::string> &settings, const std::string &fname ) {
std::ifstream in( fname.cstr() );
if ( !in )
return false;
std::string line;
size_t colonPosition;
while ( std::getline( in, line ) ) {
colonPosition = line.find( ":" );
if ( colonPosition != std::string::npos ) // not found
settings[line.substr( 0, colonPosition)] = line.substr(colonPosition+1);
}
return true;
}
(note, hasn't been tested. Might have to modify)
And the settings file would be like:
NAME:twomers
AGE:22
Then I'd call it like:
#include <fstream>
#include <string>
#include <map>
#include <iostream>
bool readSettings( std::map<std::string,std::string> &settings, const std::string &fname ) {
std::ifstream in( fname.cstr() );
if ( !in )
return false;
std::string line;
size_t colonPosition;
while ( std::getline( in, line ) ) {
colonPosition = line.find( ":" );
if ( colonPosition != std::string::npos ) // not found
settings[line.substr( 0, colonPosition)] = line.substr(colonPosition+1);
}
return true;
}
int main() {
std::map<std::string,std::string> settings;
readSettings( settings, "settings.txt" );
std::cout<< settings["NAME"] << " is " << settings["AGE"] << " years old\n";
return 0;
}
Note though that this doesn't validate the existence of these elements in the map. If you don't know a map is something which correlates one variable to another, here one string to another. The first describes the second in a unique way.