libini/test.c

34 lines
949 B
C
Raw Normal View History

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