📄 subject_38743.htm
字号:
<p>
序号:38743 发表者:foolish 发表日期:2003-05-05 21:39:47
<br>主题:如何得到文件的大小
<br>内容: 如何直接得到文件的大小。谢了。
<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 <io.h><BR>#include <fcntl.h><BR>#include <sys/types.h><BR>#include <sys/stat.h><BR>#include <stdio.h><BR><BR>void main( void )<BR>{<BR> int fh, result;<BR> unsigned int nbytes = BUFSIZ;<BR><BR> /* Open a file */<BR> if( (fh = _open( "data", _O_RDWR | _O_CREAT, _S_IREAD <BR> | _S_IWRITE )) != -1 )<BR> {<BR> printf( "File length before: %ld\n", _filelength( fh ) );<BR> if( ( result = _chsize( fh, 329678 ) ) == 0 )<BR> printf( "Size successfully changed\n" );<BR> else<BR> printf( "Problem in changing the size\n" );<BR> printf( "File length after: %ld\n", _filelength( fh ) );<BR> _close( fh );<BR> }<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 + -