c语言文件操作sfdjr
文件管理功能
文件打开/关闭
FILE,*infile,=fopen(ride? ) )、腼腆的项链);
flose(INF自定义e );
文件读取:
Fgetc:
格式: int fgetc (文件^流);
readsacharacterfromthefilepointingtothefilepointerstream?
thereturnvalueofthisfunctionisabytethatreturnstheread.returns eof (-1 ) ifitreadattheendofthefileorwhentheeerrrorisread。
Fgets:
theprototypeischar*fgets(char、*s、int、n、FILE、* stream );
Parameter:
* s : characterpointertothedataaddressthatwillbestored。
n :集成数据,whichreadsn-1 charactersfromthestream。
^stream: pointer data,the stream to read。
功能:
readntcharactersfromthefilepointerstream,saveinthespacewheresisthestartingaddress,until you have completed a row,andifsucccescestestred
Fscanf:
Function name: fscanf
function : performsformattedinputfromastream,fscanfendswithspacesandlinebreaks,and ends with spaces? This is different from fgets,wherefgetsencountersspacesthatdonotend。
Usage: int,fscanf (文件、^stream、char、^format、
int fscanf (文件指针,格式字符串,输入列表);
Example:wldny,%s%d%lf,a,b,c )
Return value: integer,valueequaltothenumberof [ argument? _
Fread:
Function prototypes: size_t,fread(void、^buffer、size_t、size、size_t、count、FILE、^stream );
function : readdatafromafilestream,read count elements,each element size bytes? If the call succeeds,返回计数? If the call is successful,theactualreadsize * countbytesareread
Parameter:
buffer : isusedtoreceivedatamemoryaddresses,at least size*count bytes in size
size : thesizeofasingleelement,in bytes
The number of count: elements,each of which is size bytes? stream :输入流
return value 3360 thenumberofelementsactuallyread.ifthereturnvalueisnotthesameascount,theendorerrorofthe
getstheerrorinformationfromferrorandf