English 中文(简体)
从组合档案中确定和获取价值观
原标题:Setting and getting the values from configuration file
  • 时间:2010-06-28 05:13:04
  •  标签:
  • c
  • linux

我正在使用Claran语和Lino作为我的方案拟订平台。

在我的抽样申请中。 我想获得并确定一个海关组合档案的价值。 下面是我的议事档案的结构。

idlevalue=5
sleeping=1

现在,我的问题是,在我的申请中,我很难思考如何落实既定职能。

我计划查阅档案的所有内容。 然后确定点人的具体价值,然后改变价值。 然后将所有数据再次输入档案。

这似乎在混淆档案中树立了一种价值,远远没有达到。

请提出咨询意见。

问题回答

https://stackoverflow.com/questions/147902/linux-configuration-file-libraries” SO。

设有图书馆,例如libconfig,为你处理这类问题。

EDIT:我删除了“登革处理作为数据库,了解你在概念上如何对待......”。 想法是,在编织物的顶端备有一份标本:

书写代码,将所有变量进行分类并读为记忆。 在保存汇号时,只是再次节省所有变数,而不是试图找到一个具体变数,只修改该具体变数的价值。

这样做是好的:

char *config_file_path = "/foo/bar.conf";
struct config {...} myconfig;
read_config(config_file_path, &myconfig);
// set a value
myconfig.somevalue = 5;
// When re-writing, routine simply over-writes the entire file.
write_config(config_file_path, &myconfig);

只有当用户拯救大火时,你才需要书写文件,因此,在你准备这样做时,它就是一个巨大的瓶颈。

Sure - 硬部分是,你想要替换的数据可能与你想要用的数据相差。

通常的解决办法,特别是简单简便的文件,是简单地从记忆中写出一个完整的新文件,其中载有all<>m>>>。 页: 1 (这一程序意味着,即使你的申请或计算机坠毁,在撰写公文档案时,你也用腐败的公交文件打上了头。)

As per me obviously getting the data from a file is easier. For changing the values there is one easier solution that you have all the data in some structure and when you want to change some values change them in structure and then copy the whole structure back to file.

如果只有一个改动,而且你不愿意将全部数据重新写到档案中,那么,你只能通过阅读“申请”方式的档案来改变所需要的价值,并寻求你的名字价值,然后改变价值。 它比照再次提交的所有数据,而是更好地做你想要的。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签