INI-Files under Linux with C++

Posted on 2006-05-10
Last Modified: 2012-05-05
I want to use INI-Files under linux to be compatible between windows and linux.

as far as i know there are not functions for ini files under linux.

do someone know a free library or something like that?

Kind Regards woigl
Question by:woigl

    Author Comment

    What i exactly looking for is some functions to handle ini files under linux.

    Could be a library or even a source...

    Regards Stefan
    LVL 5

    Expert Comment

    writing your own is simple enough. Simply open the file as text, read each line. Group headers are bracketed with angle brackets i.e [Header] and then following a header you have your options separated from their values by an =.

    #include <string>
    #include <fstream>
    using namespacestd;
    int main()
        ifstream inifile("myfile.ini");
        string line;
        bool foundheader=false,foundoption=false;
            //now parse the each line to check when you are in the correct header
            //once in the correct header look for the option
           //split the line at the = and use the second part (after =) as the value you are looking for
        return 0;

    LVL 53

    Accepted Solution

    Check the bottom of this page :

    It has a few links to C/C++ libraries for parsing INI files.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
    What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now