【发布时间】:2015-10-02 18:56:05
【问题描述】:
我创建了一个如下所示的 .ini 文件:
[one]
heading=" available state";
name=['A', 'D', 'H'];
[two]
type= ["on", "off", "switch"];
访问这个ini文件的主C程序如下所示:
#include <stdio.h>
#include <Windows.h>
int main ()
{
LPCSTR ini = "C:\coinfiguration.ini";
char returnValue1[100];
char returnValue2[100];
GetPrivateProfileString("states", "title", 0, returnValue1, 100, ini);
GetPrivateProfileString("reaction", "reac_type", 0, returnValue2, 100, ini);
printf(returnValue2[10]);
printf("%s \n" ,returnValue1);
printf(returnValue2);
return 0;
}
我能够显示第一组的整个标题以及整个数组名称。但不是像这样显示整个数组(名称)
['A', 'D', 'H'];
我只想显示术语“A”。 同样对于第二节而不是这个
["on", "off", "switch"];
我只想把“打开”。 我想不出办法来做到这一点。有人可以帮帮我吗?
【问题讨论】:
-
所谓的INI files 没有“数组”或列表或任何此类数据。像您展示的“数组”是特定于应用程序的,您需要自己解析它。
-
@Joachim Pileborg:感谢您的回复。但是你能告诉我如何解析它吗?提前谢谢..
标签: c configuration ini