0

This is my first attempt at creating a config file in C. I have done in Python before. For developing it in python I had used the following link. Could somebody tell me a way to do this in C?

What I am trying to create is a config file with a list of certain states for a button, different application names, etc and access them from my main C program?

I have not added any code here because I have no idea on how to go about creating the configuration file in c. Please help

Anamika Ana
  • 165
  • 1
  • 3
  • 11
  • You can either use a library (like e.g.https://github.com/compuphase/minIni) or write the parser yourself. What is your goal? – undur_gongor Jul 13 '15 at 09:43
  • @undur_gongor: My final aim is to declare the names of States, Applications , an Array with the tree structure and other such information in the config file and then try to access this from my Main C program. – Anamika Ana Jul 13 '15 at 09:49

1 Answers1

1

look at libconfig for example. If your config file is something custom with not too complicated structure, you also can write it on your own, obviously. Googling for "c file IO" will point you in the right directions. XML would also be a idea, if the data is very complex. For example: link.

jwsc
  • 867
  • 8
  • 15
  • @jswc: Thank you for that comment. I want to write my own config file. But what I dont understand is how doe I do this? Could you maybe give me an example please? – Anamika Ana Jul 13 '15 at 10:01
  • 2
    @Anamika Ana For instructions how to write files in C you only have to use google: http://www.cprogramming.com/tutorial/cfileio.html, http://stackoverflow.com/questions/11573974/write-to-txt-file, http://www.tutorialspoint.com/cprogramming/c_file_io.htm You will find something out there. – jwsc Jul 13 '15 at 10:04