1 Star 0 Fork 0

wwwsh0510/博物馆讲解系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
config.c 668 Bytes
一键复制 编辑 原始数据 按行查看 历史
wwwsh0510 提交于 2024-07-04 16:53 . 调用创建会话API
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
//读取配置信息
cJSON* read_config(const char* file)
{
//读取json文件内容
FILE* fp = fopen(file, "r");
if (!fp) {
perror(file);
return NULL;
}
//移动文件指针到文件末尾
fseek(fp, 0, SEEK_END);
//获取文件大小
long size = ftell(fp);
//移动文件指针到文件开头
fseek(fp, 0, SEEK_SET);
//将文件内容读取到缓冲区中
char* buffer = (char*)malloc(size + 1);
fread(buffer, 1, size, fp);
fclose(fp);
//将缓冲区中的内容转换为json对象
return cJSON_ParseWithLength(buffer, size);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wwwsh0510/museum-self-explanation-system.git
git@gitee.com:wwwsh0510/museum-self-explanation-system.git
wwwsh0510
museum-self-explanation-system
博物馆讲解系统
master

搜索帮助