📄 c源码_cfg-_ini配置文件读写测试程序.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0060)http://fanqiang.chinaunix.net/a4/b9/20010819/1305001148.html -->
<HTML><HEAD><TITLE>[ 永远的UNIX > C源码:.CFG/.INI配置文件读写测试程序 ]</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>BODY {
FONT: 12pt 宋体
}
TH {
FONT: 12pt 宋体
}
INPUT {
FONT: 12pt 宋体
}
SELECT {
FONT: 12pt 宋体
}
TEXTAREA {
FONT: 12pt 宋体
}
SELECT {
FONT: 12pt 宋体
}
checkbox {
FONT: 12pt 宋体
}
A:link {
COLOR: #e6a306; TEXT-DECORATION: underline
}
A:visited {
COLOR: #e6a306; TEXT-DECORATION: underline
}
A:hover {
COLOR: #ffff00; TEXT-DECORATION: underline
}
BODY {
FONT-SIZE: 12pt; FONT-FAMILY: "宋体", "serif"
}
TD {
FONT-SIZE: 12pt; FONT-FAMILY: "宋体", "serif"
}
P {
FONT-SIZE: 9pt; LINE-HEIGHT: 150%
}
</STYLE>
<META content="MSHTML 6.00.2900.2523" name=GENERATOR></HEAD>
<BODY text=#ffffff bgColor=#000000
background=C源码_CFG-_INI配置文件读写测试程序.files/bline.gif>
<DIV align=center>
<CENTER>
<TABLE height=400 cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD height=45>
<P align=center><IMG alt="[ 永远的UNIX::UNIX技术资料的宝库 ]"
src="C源码_CFG-_INI配置文件读写测试程序.files/title.gif"></P></TD></TR>
<TR>
<TR>
<TD vAlign=bottom align=left height=40><SMALL><A
href="http://fanqiang.chinaunix.net/">首页</A> > 编程技术 > 源码天堂 >
正文</SMALL></TD></TR>
<TR>
<TD width="100%" bgColor=#d09f0d colSpan=5 height=2><IMG height=1
src="C源码_CFG-_INI配置文件读写测试程序.files/c.gif" width=1></TD></TR>
<TR>
<TD vAlign=center align=middle height=40><FONT
size=5><B>C源码:.CFG/.INI配置文件读写测试程序</B></FONT></TD></TR>
<TR>
<TD align=middle height=20><FONT
color=#999999><SMALL>本文出自:http://mly363.363.net 作者: (2001-08-19
13:05:00)</SMALL></FONT></TD></TR>
<TR>
<TD align=middle>
<TABLE cellSpacing=0 cellPadding=0 width=700 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top><FONT
color=#cccccc>/* CFG-TEST.C --- Test .CFG/.INI file read/write
<BR> (C) M.L.Y 2000.12 <BR>*/
<BR><BR>#if __OS400__ /* AS/400 */
<BR> #include "GCFTXTFC"
<BR> #include "GCFSTRC" <BR>#else
<BR># include "GCFTXTF.C"
<BR># include "GCFSTR.C" <BR>#endif <BR><BR>main() <BR>{
<BR> USGC cfg_file[255], section[255], key[255], val[1024];
<BR> char get_set[255], yn[255];
<BR> int rc;
<BR><BR> printf("CFG-TEST --- Test .CFG/.INI file read/write\n");
<BR> printf("(C) M.L.Y 2000.12\n\n");
<BR> printf("Please input .INI/.CFG file name:");
<BR> gets((char *)cfg_file);
<BR> while(1) <BR> {
<BR> printf("get/set(G/S)?");
<BR> gets(get_set);
<BR> ltrimstr(rtrimstr(get_set));
<BR> if(get_set[0] == 'g' || get_set[0] == 'G' ||
<BR> get_set[0] == 's' || get_set[0] == 'S')
<BR> break; <BR> }
<BR> printf("Please input section name:");
<BR> gets((char *)section);
<BR> printf("Please input key name:");
<BR> gets((char *)key);
<BR> if(get_set[0] == 's' || get_set[0] == 'S')
<BR> {
<BR> printf("Please input key value:");
<BR> gets((char *)val);
<BR> }
<BR> printf("\nFilename='%s', operation='%c',\n", cfg_file, get_set[0]);
<BR> printf("section=[%s], key='%s'\n", section, key);
<BR> if(get_set[0] == 's' || get_set[0] == 'S')
<BR> printf("key value='%s'\n", val);
<BR> printf("Are you sure(Y/N)?");
<BR> gets(yn); <BR> ltrimstr(rtrimstr(yn));
<BR> if(yn[0] != 'y' && yn[0] != 'Y') return 0;
<BR> if(get_set[0] == 's' || get_set[0] == 'S')
<BR> rc = CFG_set_key(cfg_file, section, key, val);
<BR> else <BR> {
<BR> rc = CFG_get_key(cfg_file, section, key, val);
<BR> if(rc == 0)
<BR> printf("Key value='%s'\n", val);
<BR> }
<BR> printf("Return code = %d\n", rc);
<BR> return rc; <BR>}
<BR><BR>/* End of file */ <BR>(<A
href="http://www.fanqiang.com/">http://www.fanqiang.com/</A>)
</FONT> 进入【<A
href="http://www.chinaunix.net/">UNIX论坛</A>】 </TD></TR>
<TR>
<TD>
<HR>
</TD></TR>
<TR>
<TD><B>相关文章</B> </TD></TR>
<TR>
<TD><A
href="http://fanqiang.chinaunix.net/a4/b9/20010819/0905001147.html">C源码:通用C语言函数:文本文件有关操作,.CFG/.INI类配置文件读写(对应.C的头文件
)</A> <SMALL>(2001-08-19 09:05:00)</SMALL></FONT><BR><A
href="http://fanqiang.chinaunix.net/a4/b9/20010819/0805001146.html">C源码:通用C语言函数:文本文件有关操作,.CFG/.INI类配置文件读写</A>
<SMALL>(2001-08-19 08:05:00)</SMALL></FONT><BR></TD></TR>
<TR>
<TR>
<TD></TD></TR>
<TR>
<TD> </TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD width="100%" bgColor=#d09f0d colSpan=5 height=2><IMG height=1
src="C源码_CFG-_INI配置文件读写测试程序.files/c.gif" width=1></TD></TR>
<TR>
<TD vAlign=top width="100%" colSpan=5 height=40>
<P align=center><FONT color=#ffffff>★ 樊强制作 欢迎分享 ★
</FONT></P></TD></TR></TBODY></TABLE></CENTER></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -