我有settings.cfg,其中存储了一些信息。出于学习目的,我将在这里发布非常小的settings.cfg
application =
{
strings =
{
hellostring = "hello";
}
};
我可以阅读价值,并将其与短代码,不包含和主
一起变为可变 libconfig::Config cfg;
std::string helloVariable = cfg.lookup("application.strings.hellostring");
std::cout << "Lets cout what we loaded from cfg: " << helloVariable;
// lets modify helloVariable
helloVariable = "hello world";
// how to store modified variable into .cfg, not adding, just modifying
// within libconfig++ code, without recreating entire .cfg file with fstream
return 0;
我正在使用libconfig ++ 1.4.9。 信息:我来自手机,因此代码可能会破坏而且格式不合理