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

📄 c105.htm

📁 经典c语言教程
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件操作的专用函数</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<script language="javascript">
   var prePage="http://www.nec.sjtu.edu.cn/support/Course/C/c/c10/c/c10/c104.htm";
   var nextPage="c/c10/c106.htm";
	function showwin(url,winname,properties){
		window.open(url,winname,properties)
	}

</script>

<link rel="stylesheet" href="../cstyle.css" type="text/css">
<bgsound src="../voice/c105.au" loop="1">
</head>

<body background="../img/mainback.jpg" bgproperties="fixed">

<h2 align="center"><font face="楷体_GB2312"><a name="_top"></a>10.5 
文件操作的专用函数</font></h2>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%" align="center"><a href="c105.htm#c1051.html#c1051">函数的使用和例子</a></td>
    <td width="50%" align="center"><a href="c105.htm#c1052.html#c1052">练习题</a></td>
  </tr>
</table>

<hr>

<h3><a name="c1051"></a>1.函数的使用和例子</h3>

<blockquote>
  <p>大多数情况下, 在标准文件上操作已足够了。但是, 
  我们有时要在一般文件上操作, 这就要用到其它一些函数, 例如:<br>
  fopen(),fclose(),fscanf(),fprintf()</p>
  <p>如果你想打开文件 FILE1,例如,fi=fopen(&quot;FILE1&quot;,&quot;w&quot;); <br>
  &quot;w&quot; 表示打开方式为写入。<br>
  fopen() 的返回值是指针。<br>
  </p>
  <p>如果你想关闭已打开的 FILE1,可以用 fclose(fi);<br>
  于是既不能读, 也不能写文件 FILE1 了。</p>
  <p>如果你想读文件 FILE1,<br>
  fi=fopen(&quot;FILE1&quot;,&quot;r&quot;);<br>
  fscanf(fi,&quot;%s&quot;,str);从文件 FILE1 中读取了一个字符串。</p>
  <p><br>
  如果你想把数据写入一个打开的文件 FILE1, <br>
  fprintf(fi,&quot;general file&quot;);<br>
  你可以看到, 数据 &quot;general file&quot;将被写入到 FILE1 中。<br>
  <br>
  </p>
  <p align="right"><a href="c105.htm#_top.html#_top">返回页首</a></p>
</blockquote>

<hr>

<h3><a name="c1052"></a>2.练习题</h3>

<blockquote>
  <p> </p>
  <p align="right"><a href="c105.htm#_top.html#_top">返回页首</a></p>
</blockquote>

<p align="center"><a href="http://www.nec.sjtu.edu.cn/support/Course/C/c/c10/c106.htm"><img src="../img/next.gif" width="145" height="30"
alt="next.gif (3633 bytes)" border="0"></a></p>
</body>
</html>

⌨️ 快捷键说明

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