ImageVerifierCode 换一换
格式:DOCX , 页数:27 ,大小:25.56KB ,
资源ID:19376437      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19376437.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(文件操作主要函数Word文档下载推荐.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

文件操作主要函数Word文档下载推荐.docx

1、LibrariesLIBC.LIBSingle thread static library, retail versionLIBCMT.LIBMultithread static library, retail versionMSVCRT.LIBImport library for MSVCRT.DLL, retail versionThe c, n, and t mode options are Microsoft extensions for fopen and _fdopen and should not be used where ANSI portability is desired

2、.Return ValueEach of these functions returns a pointer to the open file. A null pointer value indicates an error. ParametersfilenameFilenamemodeType of access permittedRemarksThe fopen function opens the file specified by filename. _wfopen is a wide-character version of fopen; the arguments to _wfop

3、en are wide-character strings. _wfopen and fopen behave identically otherwise.Generic-Text Routine MappingsTCHAR.H Routine _UNICODE & _MBCS Not Defined_MBCS Defined_UNICODE Defined_tfopenThe character string mode specifies the type of access requested for the file, as follows:rOpens for reading. If

4、the file does not exist or cannot be found, the fopen call fails.wOpens an empty file for writing. If the given file exists, its contents are destroyed.aOpens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if

5、 it doesnt exist.r+Opens for both reading and writing. (The file must exist.)w+Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.a+Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is w

6、ritten to the file and the EOF marker is restored after writing is complete;When a file is opened with the or access type, all write operations occur at the end of the file. The file pointer can be repositioned using fseek or rewind, but is always moved back to the end of the file before any write o

7、peration is carried out. Thus, existing data cannot be overwritten.The mode does not remove the EOF marker before appending to the file. After appending has occurred, the MS-DOS TYPE command only shows data up to the original EOF marker and not any data appended to the file. The mode does remove the

8、 EOF marker before appending to the file. After appending, the MS-DOS TYPE command shows all data in the file. The mode is required for appending to a stream file that is terminated with the CTRL+Z EOF marker.When the , , or access type is specified, both reading and writing are allowed (the file is

9、 said to be open for “update”). However, when you switch between reading and writing, there must be an intervening fflush, fsetpos, fseek, or rewind operation. The current position can be specified for the fsetpos or fseek operation, if desired.In addition to the above values, the following characte

10、rs can be included in mode to specify the translation mode for newline characters:tOpen in text (translated) mode. In this mode, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading/writing with , fopen checks for a CTRL+Z at the end of the file and removes it, if

11、possible. This is done because using fseek and ftell to move within a file that ends with a CTRL+Z, may cause fseek to behave improperly near the end of the file. Also, in text mode, carriage returnlinefeed combinations are translated into single linefeeds on input, and linefeed characters are trans

12、lated to carriage returnlinefeed combinations on output. When a Unicode stream-I/O function operates in text mode (the default), the source or destination stream is assumed to be a sequence of multibyte characters. Therefore, the Unicode stream-input functions convert multibyte characters to wide ch

13、aracters (as if by a call to the mbtowc function). For the same reason, the Unicode stream-output functions convert wide characters to multibyte characters (as if by a call to the wctomb function).bOpen in binary (untranslated) mode; translations involving carriage-return and linefeed characters are

14、 suppressed. If t or b is not given in mode, the default translation mode is defined by the global variable _fmode. If t or b is prefixed to the argument, the function fails and returns NULL. For more information about using text and binary modes in Unicode and multibyte stream-I/O, see Text and Bin

15、ary Mode File I/O and Unicode Stream I/O in Text and Binary Modes.cEnable the commit flag for the associated filename so that the contents of the file buffer are written directly to disk if either fflush or _flushall is called.nReset the commit flag for the associated filename to “no-commit.” This i

16、s the default. It also overrides the global commit flag if you link your program with COMMODE.OBJ. The global commit flag default is “no-commit” unless you explicitly link your program with COMMODE.OBJ.Valid characters for the mode string used in fopen and _fdopen correspond to oflag arguments used

17、in _open and _sopen, as follows.Characters in mode StringEquivalent oflag Value for _open/_sopena_O_WRONLY | _O_APPEND (usually _O_WRONLY | _O_CREAT | _O_APPEND)a+_O_RDWR | _O_APPEND (usually _O_RDWR | _O_APPEND | _O_CREAT )r_O_RDONLYr+_O_RDWRw_O_WRONLY (usually _O_WRONLY | _O_CREAT | _O_TRUNC)w+_O_

18、RDWR (usually _O_RDWR | _O_CREAT | _O_TRUNC)_O_BINARY_O_TEXTNoneExample/* FOPEN.C: This program opens files named data * and data2.It uses fclose to close and * _fcloseall to close all remaining files. */#include FILE *stream, *stream2;void main( void ) int numclosed; /* Open for read (will fail if

19、file does not exist) */ if( (stream = fopen( ) = NULL ) printf( The file data was not openedn ); else was openedn /* Open for write */ if( (stream2 = fopen( data2 /* Close stream */ if( fclose( stream ) ) was not closedn /* All other files are closed: numclosed = _fcloseall( );Number of files closed

20、 by _fcloseall: %un, numclosed );Output was opened 1Stream I/O RoutinesSee Alsofclose, _fdopen, ferror, _fileno, freopen, _open, _setmodefclose, _fcloseallCloses a stream (fclose) or closes all open streams (_fcloseall).int fclose( FILE *stream );int _fcloseall( void );fclose_fcloseallfclose returns

21、 0 if the stream is successfully closed. _fcloseall returns the total number of streams closed. Both functions return EOF to indicate an error.ParameterstreamPointer to FILE structureThe fclose function closes stream. _fcloseall closes all open streams except stdin, stdout, stderr (and, in MS-DOS, _

22、stdaux and _stdprn). It also closes and deletes any temporary files created by tmpfile. In both functions, all buffers associated with the stream are flushed prior to closing. System-allocated buffers are released when the stream is closed. Buffers assigned by the user with setbuf and setvbuf are no

23、t automatically released. _close, _fdopen, fflush, fopen, freopenfwriteWrites data to a stream.size_t fwrite( const void *buffer, size_t size, size_t count, FILE *stream );fwrite returns the number of full items actually written, which may be less than count if an error occurs. Also, if an error occurs, the file-position indicator cannot be determined.bufferPointer to data to be writtensizeItem size in bytescountMaximum number of items to be writtenThe fwrite funct

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1