Question

There are some similar questions about C++, Java and C# so now my question is about C. If I have this config file

[BBDD]
user=**
password=***
database=***
IPServidor=*
port=3***

[Device]
dev=8
Temperatura=5=1001
Humedad=7=1002
Link=8=1003
Volt=9=1004

[Device]
dev=10
Temperatura=5=1012
Humedad=7=1013
Link=8=1014
Volt=9=1015

what is the best way to read the values of Device. I am a linux user. I used glib but I had some problems because there is the same key (Device) so it returns me as the tutorial says only the values of the last Device array. Also Boost as I know has libraries for C++, libconfig also I think is not used for this kind of config files. Finally iniparser has a difficult installation guide for me. Do you think that some solutions like sscanf, fprintf are good?

Was it helpful?

Solution 2

What problems are you having with using iniparser? I just tried it. I first did make in the iniparser directory, and the code was built. To use the library, I did the following:

gcc test.c ./libiniparser.a

This was because I had created the test program in the same directory as the library. When you include iniparser.h in C++, make sure to do the following:

extern "C"
{
#include "src/iniparser.h"
}

OTHER TIPS

Finally iniparser has a difficult installation guide for me. Do you think that some solutions like sscanf, fprintf are good?

The iniparser may have a difficult installation, but that's a small tradeoff for code that already works, has already been tested, and handles cases that you haven't thought of.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top