2019-06-27 20:45:31 +08:00
|
|
|
|
#include "libini.h"
|
|
|
|
|
#include <stdio.h>
|
2019-07-02 11:15:11 +08:00
|
|
|
|
#include <string.h>
|
2019-06-27 20:45:31 +08:00
|
|
|
|
|
2019-07-02 11:15:11 +08:00
|
|
|
|
int main(void)
|
|
|
|
|
{
|
2019-06-27 20:45:31 +08:00
|
|
|
|
|
|
|
|
|
char buf[50];
|
2019-07-02 11:15:11 +08:00
|
|
|
|
getinikeystring("CAT", "age", "config.ini", buf); // 字符串
|
2019-06-27 20:45:31 +08:00
|
|
|
|
printf("%s\n", buf);
|
2019-07-02 11:15:11 +08:00
|
|
|
|
memset(buf, 0, 50);
|
|
|
|
|
getinikeystring("CAT", "name", "config.ini", buf); // 字符串
|
2019-06-27 20:45:31 +08:00
|
|
|
|
printf("%s\n", buf);
|
2019-07-02 11:15:11 +08:00
|
|
|
|
memset(buf, 0, 50);
|
2019-06-27 20:45:31 +08:00
|
|
|
|
|
2019-07-02 11:15:11 +08:00
|
|
|
|
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
|
|
|
|
|
2019-07-02 11:15:11 +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);
|
2019-07-02 11:15:11 +08:00
|
|
|
|
memset(buf, 0, 50);
|
|
|
|
|
|
|
|
|
|
getinikeystring("TAC", "f", "config.ini", buf);
|
|
|
|
|
printf("%s\n", buf);
|
|
|
|
|
memset(buf, 0, 50);
|
|
|
|
|
|
2019-06-27 20:45:31 +08:00
|
|
|
|
return 1;
|
2019-07-02 11:15:11 +08:00
|
|
|
|
}
|