libini/test.c

23 lines
711 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>
int main(void) {
char buf[50];
getinikeystring("CAT", "age", "config.ini", buf); // 字符串
printf("%s\n", buf);
getinikeystring("CAT", "name", "config.ini", buf); // 字符串
printf("%s\n", buf);
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", "!@#$%^&*()_+", "config.ini"); // 写入
getinikeystring("TAC", "e", "config.ini", buf);
printf("%s\n", buf);
return 1;
}