fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <boost/property_tree/ptree.hpp>
  4. #include <boost/property_tree/ini_parser.hpp>
  5.  
  6. int main()
  7. {
  8. boost::property_tree::ptree pt;
  9. read_ini(std::cin, pt);
  10. for (const auto &section : pt) {
  11. for (const auto &kv : section.second) {
  12. std::cout << section.first << " : " << kv.first << " : " << kv.second.get_value<std::string>() << std::endl;
  13. }
  14. }
  15. }
  16.  
Success #stdin #stdout 0s 15272KB
stdin
[sec1]
key1=val1

[sec2]
key2=val2

stdout
sec1 : key1 : val1
sec2 : key2 : val2