linux下ini文件怎么打开乱码,请教linux(C语言)下标准ini文件的读取,写入?配置管理...

各位大师:

windows下ini文件的标准格式及配置管理搞定(采用了WINDOWS API函数),

现在程序要移植到linux平台上,请教各位:

那linux下(C语言)如何对ini文件进行读取,写入??

谢谢!

|

/************************************************************************

T h e   O p e n   W i n d o w s   P r o j e c t

------------------------------------------------------------------------

Filename   : IniFile.h

Author(s)  : Carsten Breuer

------------------------------------------------------------------------

Copyright (c) 2000 by Carsten Breuer (C.Breuer@openwin.de)

************************************************************************/

#ifndef __INIFILE_H__

#define __INIFILE_H__

//#ifdef LINUX /* Remove CR, on unix systems. */

#define INI_REMOVE_CR

#define DONT_HAVE_STRUPR

//#endif

#define tpNULL       0

#define tpSECTION    1

#define tpKEYVALUE   2

#define tpCOMMENT    3

struct ENTRY{

char   Type;

char  *Text;

struct ENTRY *pPrev;

struct ENTRY *pNext;

};

struct ENTRY ENTRY;

typedef struct{

struct ENTRY *pSec;

struct ENTRY *pKey;

char          KeyText[128];

char          ValText[128];

char          Comment[255];

}EFIND;

/* Macros */

#define ArePtrValid(Sec,Key,Val) ((Sec!=NULL)&&(Key!=NULL)&&(Val!=NULL))

/* Connectors of this file (Prototypes) */

char    OpenIniFile (const char *FileName);

char    Readchar    (const char *Section, const char *Key, char   Default);

int     ReadInt     (const char *Section, const char *Key, int    Default);

double  ReadDouble  (const char *Section, const char *Key, double Default);

const char   *ReadString  (const char *Section, const char *Key, const char  *Default);

void    Writechar   (const char *Section, const char *Key, char   Value);

void    WriteInt    (const char *Section, const char *Key, int    Value);

void    WriteDouble (const char *Section, const char *Key, double Value);

void    WriteString (const char *Section, const char *Key, const char  *Value);

charDeleteKey (const char *Section, const char *Key);

char DeleteSection(const char *Section);//FIXME:这是我加的

void    CloseIniFile ();

char    WriteIniFile (const char *FileName);

#endif /*__INIFILE_H__*/

你在GOOGLE CODE中搜索这个文件就可以了。

记得使用字符串操作的时候,返回字符串需要strcpy下,因为返回的是个全局变量,后边还会被使用掉

|

GTK 2.0 编程范例

这本书里第八章有介绍ini配置文件的生成读写的内容

可以去看看

书有很多地方可以下,CSDN就有

至少可以照着写,应该可以解决问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值