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

📄 subject_38743.htm

📁 vc
💻 HTM
字号:
<p>
序号:38743 发表者:foolish 发表日期:2003-05-05 21:39:47
<br>主题:如何得到文件的大小
<br>内容:&nbsp;&nbsp; 如何直接得到文件的大小。谢了。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:擎天柱 回复日期:2003-05-05 21:48:52
<br>内容:/* CHSIZE.C: This program uses _filelength to report the size<BR> * of a file before and after modifying it with _chsize.<BR> */<BR><BR>#include &lt;io.h&gt;<BR>#include &lt;fcntl.h&gt;<BR>#include &lt;sys/types.h&gt;<BR>#include &lt;sys/stat.h&gt;<BR>#include &lt;stdio.h&gt;<BR><BR>void main( void )<BR>{<BR>&nbsp;&nbsp; int fh, result;<BR>&nbsp;&nbsp; unsigned int nbytes = BUFSIZ;<BR><BR>&nbsp;&nbsp; /* Open a file */<BR>&nbsp;&nbsp; if( (fh = _open( "data", _O_RDWR | _O_CREAT, _S_IREAD <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | _S_IWRITE ))&nbsp;&nbsp;!= -1 )<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf( "File length before: %ld\n", _filelength( fh ) );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( ( result = _chsize( fh, 329678 ) ) == 0 )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf( "Size successfully changed\n" );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf( "Problem in changing the size\n" );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf( "File length after:&nbsp;&nbsp;%ld\n", _filelength( fh ) );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_close( fh );<BR>&nbsp;&nbsp; }<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

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