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
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
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,foundopt ion=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;
#include <string>
#include <fstream>
using namespacestd;
int main()
{
ifstream inifile("myfile.ini");
string line;
bool foundheader=false,foundopt
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could be a library or even a source...
Regards Stefan