Prompt any site where at least something is working about ini files in C ++. Did not find any working script. Some left libraries are unknown from where, etc. Namely, how to work with them.

  • one
    write your parser - b2soft
  • 2
    I think that ini-files do not have a generally accepted format, so you have to write your solution (parser) for your specific format. In general, I agree with the previous speaker. - VladD
  • If the author himself chooses the file format, I suggest using xml or json - there are definitely ready-made libraries for them - Katilina
  • I am a beginner C ++ programmer, I have no idea how to write my parser, etc. - Dimcheg
  • 2
    > ini-files are considered obsolete as early as Win 95 (almost 20 years already) ... and thoughtfully typed grep mbstring /etc/php5/cli/php.ini on the keyboard ... :-) - user6550

2 answers 2

If the program is supposed to be used only under Windows, then you can use the corresponding WinApi functions - http://en.wikipedia.org/wiki/INI_file#Accessing_INI_files

By the way, are you sure that you need the sections? Or, for example, the ability to list several values ​​of a parameter? Because to write a parser for about this format

 Parameter1 = 123 Parameter2 = 456 

business for one evening maximum.

    boost :: property_tree is your choice. example:

     #include <iostream> #include <string> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ini_parser.hpp> int main() { std::istringstream ini(R"( [Badgers] weight = 10 color = Badger are grey and black. )"); boost::property_tree::ptree bar; boost::property_tree::ini_parser::read_ini(ini, bar); std::cout << bar.get<std::string>("Badgers.weight") << std::endl; std::cout << bar.get<std::string>("Badgers.color") << std::endl; return 0; } 
    • Here it is more suitable. - Dimcheg
    • @ Dmitry Astafiev, and cope with this accelerator ? - avp