当前位置:网站首页>Detailed explanation of three types of high-frequency function operation of basic C programming under liinux class I - file operation function (f)
Detailed explanation of three types of high-frequency function operation of basic C programming under liinux class I - file operation function (f)
2022-07-23 06:00:00 【Zhang Tieniu (IOT)】
File manipulation functions
fput and fputs
fputc The function is used to put a character ( character constants / Character variables ) Write to disk file
General form :
ch=fputs(ch,fp);among ch Is the character to write ,fp Is a file pointer variable , If the writing is successful, the written characters will be returned , Write failure returns EOF;
fputs Similar to it , Write a string to the specified file ( String constant , String group name , Variable )
General form :
fputs( character string , The file pointer );fgetc and fgets
fgetc The function is used to read the character assignment from the specified file ch
General form :
ch=fgetc(fp);
The file must be opened by reading or writing , When the function encounters the end file character , The end of file flag will be returned EOF;
fgets Similar to it , Used to read a string from the specified file into the character array
General form :
fgets( Character array name ,n, The file pointer );//n Represents the number of strings .fprintf( write in ) and fscanf( Read )
fprintf General types of functions :
ch=fprintf( File type pointer , Format string , Input list );
fscanf General types of functions :
fscanf( File type pointer , Format string , Output list );fread and fwrite
fread It's from fp Read from file pointed to count Time , Each read size byte , The read information is saved in buffer In the address
General form :
fread(buffer,size,count,fp);
fwrite Yes, it will buffer Address start information output count Time , Every time size Bytes to fp In the file pointed to
General form :
fwrite(buffer,size,count,fp);fseek
fseek Function is used to move the position pointer inside the file
General form :
fseek( File pointer type , Displacement , The starting point );rewind
rewind The function returns the position pointer to the beginning of the file , no return value
General form :
int rewind( File type pointer );ftell
ftell Function to get the current location in the streaming file , And use the displacement relative to the file header to express
General form :
long ftell( File type pointer );边栏推荐
猜你喜欢

讀《高效閱讀法-最劃算的自我投資》有感

在局域网内配置LoRaWAN的私有ChirpStack

Basic process of sales service

Fiddler Script个性化配置显示

Common test case methods

读刘润《底层逻辑》摘录

The difference between get request and post request

Firewall Research Report
![Embedded system transplantation [1] - Guidance](/img/29/eb7e524422f061a45ea178895296a0.png)
Embedded system transplantation [1] - Guidance

Fiddler script personalized configuration display
随机推荐
Basic process of sales service
防火墙调研报告
Firewall Research Report
十月随笔
BeanShell 内置变量 ctx
get请求与post请求的区别以及抓包
A rough understanding of firewall
第四次作业:关于cat,grep,cut,sort,uniq,vim,tr等命令的用法
Learn the MD of amber t3.3: implicit solvent model (GB)
IA笔记1
UNIX编程—网络socket
迷茫的五月
点滴生活
Day 3 summary & homework
stored procedure
Jmeter上传和下载文件
Source code compilation and installation lamp
防火墙知识,原理,设备,厂商调研总结报告
Dom4j parses XML files and processes data information from XML
数值变量的运算及特殊变量