1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <string>
#include <fstream>
#include <iostream>
#include <map>
int main()
{
std::ifstream fichier( "config.txt" );
std::map< std::string, std::string > configuration;
if ( fichier )
{
std::string cle;
std::string valeur;
while ( std::getline(fichier, cle,'=') && std::getline(fichier, valeur))
configuration[cle] = valeur;
}
// Lire les valeurs
std::cout << configuration["MYSQLSERVER"] << std::endl;
std::cout << configuration["MAXUSER"] << std::endl;
std::cout << configuration["PORT"] << std::endl;
} |