原因:

1 路径错误

2 配置文件中某一行缺少=,例如用// 做注释的,前面应该加";"

解决办法:

添加异常处理,实例代码如下:

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>

boost::property_tree::ptree pt;
try
{
boost::property_tree::ini_parser::read_ini("./config.ini", pt);
}
catch(std::exception e)
{
cout<<e.what();
LOG(INFO)<<e.what();
return false;
}

m_strIP= pt.get<string>("HQSec.ip","127.0.0.1");

相关文章:

  • 2021-08-28
  • 2022-01-25
  • 2022-12-23
  • 2021-07-03
  • 2021-07-20
  • 2021-09-03
  • 2021-10-29
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案