libini/test.c

30 lines
866 B
C
Raw Normal View History

#include "libini.h"
#include <stdio.h>
#include <string.h>
int main(void)
{
2019-11-22 18:53:51 +08:00
char *tmp = NULL;
libini_memory(&tmp); // 创建内存
2019-11-22 18:53:51 +08:00
getinikeystring("CAT", "age", "config.ini", tmp); // 字符串
printf("%s\n", tmp);
getinikeystring("CAT", "name", "config.ini", tmp); // 字符串
printf("%s\n", tmp);
printf("%d\n", getinikeyint("CAT", "a", "config.ini")); // 整型
printf("%ld\n", getinikeylong("CAT", "b", "config.ini")); // 长整型
printf("%f\n", getinikeyfloat("CAT", "c", "config.ini")); // 浮点型默认小数点后6位
2019-06-29 12:06:22 +08:00
putinikeystring("TAC", "e", " abcdef!@#$%^&*()_+", "config.ini"); // 写入
2019-11-22 18:53:51 +08:00
getinikeystring("TAC", "e", "config.ini", tmp);
printf("%s\n", tmp);
2019-11-22 18:53:51 +08:00
getinikeystring("TAC", "f", "config.ini", tmp);
printf("%s\n", tmp);
2019-11-22 18:53:51 +08:00
libini_free(tmp);
return 1;
}