读取INI配置文件内容(头文件head)

本文介绍了如何通过头文件getini.h实现读取INI配置文件的功能。该头文件包含了用于打开、关闭配置文件,以及获取字符串、整型、长整型和实型数据的函数。提供了函数列表,包括OpenIniFile、CloseIniFile、GetIniString等,并且具有版本信息和修改历史记录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

其中头文件.h源代码如下:

/************************************************************
 FileName: getini.h         // 文件名称
 Author:   yuanfen127       // 作者
 Date:     2005-03-31       // 日期
 Description:               // 描述本文件的内容,功能,内部各部分之间的关系
                            // 以及文本文件与其它文件关系等
           读取指定ini文件中需要在某段中的具体值
 Version:  1.0              // 版本信息
 Function List:             // 主要函数及其功能
    1. OpenIniFile
    2. CloseIniFile
    3. GetIniString
    4. CFG_get_key
 History:         // 修改历史记录列表,每条修改记录应包括修改日期、修改
                  // 者及修改内容简述 
    1. Date:      2005-03-31
       Author:    yuanfen127
***********************************************************/
#ifndef __GETINI_H__
#define __GETINI_H__

/*在下面添加 include */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*C++ 可以直接调用此定义之间的函数*/
#ifdef __cplusplus
    extern "C" {
#endif

/*打开文件*/
int  open_ini_file(const char *pFile);
/*关闭文件*/
int  close_ini_file(void);
/*读字符串数据*/
int  get_ini_string(const char *s_section,const char *s_key, char *s_result);
/*取字符串数据*/
int  cfg_get_key(const char *pFile, const char *s_section,
                 const char *s_key, char *s_val);
/*取整型数据*/
int  cfg_get_int(const char *pFile, const char *s_section, const char *s_key);
/*取长整型数据*/
long cfg_get_long(const char *pFile, const char *s_section, const char *s_key);
/*取实型数据*/
double cfg_get_double(const char *pFile, const char *s_section,
                      const char *s_key);

#ifdef __cplusplus 
    }
#endif

#endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值