1

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?

dali1985
  • 3,263
  • 13
  • 49
  • 68

2 Answers2

5

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.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • 1
    Thank you for your answer. I agree with you and I know that iniparser is very powerful. Is there any easier installation guide for iniparser? Maybe with more clearly steps for beginners like me? – dali1985 Jul 08 '13 at 17:37
0

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"
}
user2233706
  • 6,148
  • 5
  • 44
  • 86