资源描述:
《文件资料资料资料操作主要函数》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用标准文案fopen,_wfopenOpenafile.FILE*fopen(constchar*filename,constchar*mode);FILE*_wfopen(constwchar_t*filename,constwchar_t*mode);FunctionRequiredHeaderCompatibilityfopenANSI,Win95,WinNT_wfopenorWinNTForadditionalcompatibilityinformati
2、on,seeCompatibilityintheIntroduction.LibrariesLIBC.LIBSinglethreadstaticlibrary,retailversionLIBCMT.LIBMultithreadstaticlibrary,retailversionMSVCRT.LIBImportlibraryforMSVCRT.DLL,retailversionThec,n,andtmodeoptionsareMicrosoftextensionsforfopenand_fdopenandshoul
3、dnotbeusedwhereANSIportabilityisdesired.ReturnValueEachofthesefunctionsreturnsapointertotheopenfile.Anullpointervalueindicatesanerror.ParametersfilenameFilenamemodeTypeofaccesspermittedRemarks精彩文档实用标准文案Thefopenfunctionopensthefilespecifiedbyfilename._wfopenisaw
4、ide-characterversionoffopen;theargumentsto_wfopenarewide-characterstrings._wfopenandfopenbehaveidenticallyotherwise.Generic-TextRoutineMappingsTCHAR.HRoutine_UNICODE&_MBCSNotDefined_MBCSDefined_UNICODEDefined_tfopenfopenfopen_wfopenThecharacterstringmodespecifi
5、esthetypeofaccessrequestedforthefile,asfollows:"r"Opensforreading.Ifthefiledoesnotexistorcannotbefound,thefopencallfails."w"Opensanemptyfileforwriting.Ifthegivenfileexists,itscontentsaredestroyed."a"Opensforwritingattheendofthefile(appending)withoutremovingtheE
6、OFmarkerbeforewritingnewdatatothefile;createsthefilefirstifitdoesn’texist."r+"Opensforbothreadingandwriting.(Thefilemustexist.)"w+"Opensanemptyfileforbothreadingandwriting.Ifthegivenfileexists,itscontentsaredestroyed."a+"Opensforreadingandappending;theappending
7、operationincludestheremovaloftheEOFmarkerbeforenewdataiswrittentothefileandtheEOFmarkerisrestoredafterwritingiscomplete;createsthefilefirstifitdoesn’texist.Whenafileisopenedwiththe"a"or"a+"accesstype,allwriteoperationsoccurattheendofthefile.Thefilepointercanber
8、epositionedusingfseekorrewind,but精彩文档实用标准文案isalwaysmovedbacktotheendofthefilebeforeanywriteoperationiscarriedout.Thus,existingdatacannotbeoverwritten.The"a"modedoesnotremove