⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c源码_cfg-_ini配置文件读写测试程序.htm

📁 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> &gt; 编程技术 &gt; 源码天堂 &gt; 
      正文</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>/*&nbsp;CFG-TEST.C&nbsp;---&nbsp;Test&nbsp;.CFG/.INI&nbsp;file&nbsp;read/write 
            <BR>&nbsp;&nbsp;&nbsp;(C)&nbsp;M.L.Y&nbsp;&nbsp;2000.12 <BR>*/ 
            <BR><BR>#if&nbsp;__OS400__&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;AS/400&nbsp;*/ 
            <BR>&nbsp;&nbsp;#include&nbsp;"GCFTXTFC" 
            <BR>&nbsp;&nbsp;#include&nbsp;"GCFSTRC" <BR>#else 
            <BR>#&nbsp;include&nbsp;"GCFTXTF.C" 
            <BR>#&nbsp;include&nbsp;"GCFSTR.C" <BR>#endif <BR><BR>main() <BR>{ 
            <BR>&nbsp;&nbsp;USGC&nbsp;cfg_file[255],&nbsp;section[255],&nbsp;key[255],&nbsp;val[1024]; 
            <BR>&nbsp;&nbsp;char&nbsp;get_set[255],&nbsp;yn[255]; 
            <BR>&nbsp;&nbsp;int&nbsp;&nbsp;rc; 
            <BR><BR>&nbsp;&nbsp;printf("CFG-TEST&nbsp;---&nbsp;Test&nbsp;.CFG/.INI&nbsp;file&nbsp;read/write\n"); 
            <BR>&nbsp;&nbsp;printf("(C)&nbsp;M.L.Y&nbsp;&nbsp;2000.12\n\n"); 
            <BR>&nbsp;&nbsp;printf("Please&nbsp;input&nbsp;.INI/.CFG&nbsp;file&nbsp;name:"); 
            <BR>&nbsp;&nbsp;gets((char&nbsp;*)cfg_file); 
            <BR>&nbsp;&nbsp;while(1) <BR>&nbsp;&nbsp;{ 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;printf("get/set(G/S)?"); 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;gets(get_set); 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;ltrimstr(rtrimstr(get_set)); 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;if(get_set[0]&nbsp;==&nbsp;'g'&nbsp;||&nbsp;get_set[0]&nbsp;==&nbsp;'G'&nbsp;|| 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get_set[0]&nbsp;==&nbsp;'s'&nbsp;||&nbsp;get_set[0]&nbsp;==&nbsp;'S') 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break; <BR>&nbsp;&nbsp;} 
            <BR>&nbsp;&nbsp;printf("Please&nbsp;input&nbsp;section&nbsp;name:"); 
            <BR>&nbsp;&nbsp;gets((char&nbsp;*)section); 
            <BR>&nbsp;&nbsp;printf("Please&nbsp;input&nbsp;key&nbsp;name:"); 
            <BR>&nbsp;&nbsp;gets((char&nbsp;*)key); 
            <BR>&nbsp;&nbsp;if(get_set[0]&nbsp;==&nbsp;'s'&nbsp;||&nbsp;get_set[0]&nbsp;==&nbsp;'S') 
            <BR>&nbsp;&nbsp;{ 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;printf("Please&nbsp;input&nbsp;key&nbsp;value:"); 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;gets((char&nbsp;*)val); 
            <BR>&nbsp;&nbsp;} 
            <BR>&nbsp;&nbsp;printf("\nFilename='%s',&nbsp;operation='%c',\n",&nbsp;cfg_file,&nbsp;get_set[0]); 
            <BR>&nbsp;&nbsp;printf("section=[%s],&nbsp;key='%s'\n",&nbsp;section,&nbsp;key); 
            <BR>&nbsp;&nbsp;if(get_set[0]&nbsp;==&nbsp;'s'&nbsp;||&nbsp;get_set[0]&nbsp;==&nbsp;'S') 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;printf("key&nbsp;value='%s'\n",&nbsp;val); 
            <BR>&nbsp;&nbsp;printf("Are&nbsp;you&nbsp;sure(Y/N)?"); 
            <BR>&nbsp;&nbsp;gets(yn); <BR>&nbsp;&nbsp;ltrimstr(rtrimstr(yn)); 
            <BR>&nbsp;&nbsp;if(yn[0]&nbsp;!=&nbsp;'y'&nbsp;&amp;&amp;&nbsp;yn[0]&nbsp;!=&nbsp;'Y')&nbsp;return&nbsp;0; 
            <BR>&nbsp;&nbsp;if(get_set[0]&nbsp;==&nbsp;'s'&nbsp;||&nbsp;get_set[0]&nbsp;==&nbsp;'S') 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;rc&nbsp;=&nbsp;CFG_set_key(cfg_file,&nbsp;section,&nbsp;key,&nbsp;val); 
            <BR>&nbsp;&nbsp;else <BR>&nbsp;&nbsp;{ 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;rc&nbsp;=&nbsp;CFG_get_key(cfg_file,&nbsp;section,&nbsp;key,&nbsp;val); 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;if(rc&nbsp;==&nbsp;0) 
            <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("Key&nbsp;value='%s'\n",&nbsp;val); 
            <BR>&nbsp;&nbsp;} 
            <BR>&nbsp;&nbsp;printf("Return&nbsp;code&nbsp;=&nbsp;%d\n",&nbsp;rc); 
            <BR>&nbsp;&nbsp;return&nbsp;rc; <BR>} 
            <BR><BR>/*&nbsp;End&nbsp;of&nbsp;file&nbsp;*/ <BR>(<A 
            href="http://www.fanqiang.com/">http://www.fanqiang.com/</A>) 
            </FONT>&nbsp;&nbsp;&nbsp;&nbsp;进入【<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>&nbsp;</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>★&nbsp;&nbsp;樊强制作 欢迎分享&nbsp;&nbsp;★ 
      </FONT></P></TD></TR></TBODY></TABLE></CENTER></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -