[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

INI-Files under Linux with C++

Posted on 2006-05-10
3
Medium Priority
?
2,831 Views
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
0
Comment
Question by:woigl
3 Comments
 

Author Comment

by:woigl
ID: 16648561
What i exactly looking for is some functions to handle ini files under linux.

Could be a library or even a source...

Regards Stefan
0
 
LVL 5

Expert Comment

by:gerhardschoeman
ID: 16648664
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;
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 400 total points
ID: 16648676
Check the bottom of this page :

http://en.wikipedia.org/wiki/INI_file

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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.

834 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