fork download
  1. #include <boost/property_tree/ptree.hpp>
  2. #include <boost/property_tree/ini_parser.hpp>
  3. #include <iostream>
  4. using boost::property_tree::ptree;
  5.  
  6. struct demo {
  7. int player;
  8. void load(const std::string &fname) {
  9. ptree pt;
  10. read_ini(fname, pt);
  11. player = pt.get("demo.player", 2);
  12. }
  13. void save(const std::string &fname) {
  14. ptree pt;
  15. pt.put("demo.player", player);
  16. write_ini(fname, pt);
  17. }
  18. };
  19.  
  20. int main() {
  21. try {
  22. demo ds;
  23. ds.load("demo.ini");
  24. ds.save("demo_out.ini");
  25. std::cout << "Success\n";
  26. } catch (std::exception &e) {
  27. std::cout << "Error: " << e.what() << "\n";
  28. }
  29. return 0;
  30. }
  31.  
  32.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:41: error: boost/property_tree/ptree.hpp: No such file or directory
prog.cpp:2:46: error: boost/property_tree/ini_parser.hpp: No such file or directory
prog.cpp:4: error: ‘boost’ has not been declared
prog.cpp: In member function ‘void demo::load(const std::string&)’:
prog.cpp:9: error: ‘ptree’ was not declared in this scope
prog.cpp:9: error: expected `;' before ‘pt’
prog.cpp:10: error: ‘pt’ was not declared in this scope
prog.cpp:10: error: ‘read_ini’ was not declared in this scope
prog.cpp: In member function ‘void demo::save(const std::string&)’:
prog.cpp:14: error: ‘ptree’ was not declared in this scope
prog.cpp:14: error: expected `;' before ‘pt’
prog.cpp:15: error: ‘pt’ was not declared in this scope
prog.cpp:16: error: ‘write_ini’ was not declared in this scope
stdout
Standard output is empty