Clone this repo:
  1. 1b9ee30 Merge pull request #12 from misson20000/file-constructor by Jan Tilly · 4 years, 5 months ago main master
  2. 6ad9acf Merge pull request #13 from misson20000/no-using-std-string by Jan Tilly · 4 years, 5 months ago
  3. 7bf1df9 remove 'using std::string' by misson20000 · 4 years, 5 months ago
  4. 7c9e125 add INIReader(FILE*) constructor by misson20000 · 4 years, 5 months ago
  5. f71cce3 Merge pull request #10 from kuznetsss/master by Jan Tilly · 4 years, 7 months ago


Build Status

This is a header only C++ version of inih.

inih (INI Not Invented Here) is a simple .INI file parser written in C. It‘s only a couple of pages of code, and it was designed to be small and simple, so it’s good for embedded systems. It‘s also more or less compatible with Python’s ConfigParser style of .INI files, including RFC 822-style multi-line syntax and name: value entries.


All you need to do is to include INIReader.h. Consider the following example (INIReaderTest.cpp):

#include <iostream>
#include "INIReader.h"

int main() {

    INIReader reader("test.ini");

    if (reader.ParseError() != 0) {
        std::cout << "Can't load 'test.ini'\n";
        return 1;
    std::cout << "Config loaded from 'test.ini': version="
              << reader.GetInteger("protocol", "version", -1) << ", name="
              << reader.Get("user", "name", "UNKNOWN") << ", email="
              << reader.Get("user", "email", "UNKNOWN") << ", pi="
              << reader.GetReal("user", "pi", -1) << ", active="
              << reader.GetBoolean("user", "active", true) << "\n";
    return 0;


To compile and run:

g++ INIReaderTest.cpp -o INIReaderTest.out
# Config loaded from 'test.ini': version=6, name=Bob Smith,, pi=3.14159, active=1