Link to home
Start Free TrialLog in
Avatar of woigl
woigl

asked on

INI-Files under Linux with C++

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
Avatar of woigl
woigl

ASKER

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

Could be a library or even a source...

Regards Stefan
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;
    while(getline(fin,line))
    {
        //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
    }
    inifile.close();
    return 0;
}


regards;
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial