libini/test.c
2019-11-22 18:53:51 +08:00

30 lines
866 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "libini.h"
#include <stdio.h>
#include <string.h>
int main(void)
{
char *tmp = NULL;
libini_memory(&tmp); // 创建内存
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位
putinikeystring("TAC", "e", " abcdef!@#$%^&*()_+", "config.ini"); // 写入
getinikeystring("TAC", "e", "config.ini", tmp);
printf("%s\n", tmp);
getinikeystring("TAC", "f", "config.ini", tmp);
printf("%s\n", tmp);
libini_free(tmp);
return 1;
}