当前位置:网站首页>C language file reading and writing
C language file reading and writing
2022-07-25 20:23:00 【jxb_ eight thousand eight hundred and eighty-eight】
#include <stdio.h>
#include <string.h>
// Structure statement
struct Item
{
char name[24];
float val;
};
void Writefile(Item & a)
{
strcat (a.name,"\0");
char ch;
FILE *fp;// Define the file stream pointer , Used to open a file
fp = fopen("0063120.txt","a");// Write open file
fprintf(fp ,"%s\t%0.2f\n", a.name, a.val);
fclose(fp);// Close file a, If you open it, you have to close it
}
void Readfile()
{
struct Item b;
FILE *fp;// Define the file stream pointer , Used to open a file
fp = fopen("0063120.txt","r");// Write open file
while(!feof(fp))
{
fscanf(fp, "%s\t%f", b.name, &b.val);
if(strlen(b.name) == 0) break;
printf("%s\t%0.2f\n", b.name, b.val);
memset(b.name, 0,sizeof(b.name)) ;
}
fclose(fp);
}
int main()
{
//struct Item a={ " centre post ", 2400}; // Structure definition and assignment
//Writefile(a);
Readfile();
getchar();
return 0;
}
边栏推荐
- Share 25 useful JS single line codes
- 【高等数学】【6】多元函数微分学
- Chapter VI modified specification (SPEC) class
- Arrow 之 Parquet
- wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
- [today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
- Why did I choose to become a network engineer after graduating from weak current for 3 months
- MySQL 日期【加号/+】条件筛选问题
- Log in to Baidu online disk with cookies (websites use cookies)
- RF, gbdt, xgboost feature selection methods "recommended collection"
猜你喜欢

【高等数学】【5】定积分及应用

Recommended books | essentials of industrial digital transformation: methods and Practice

Vivo official website app full model UI adaptation scheme

Kubernetes进阶部分学习笔记

wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M

Myormframeworkjdbc review and problem analysis of user-defined persistence layer framework, and thought analysis of user-defined persistence layer framework

4everland storage node portal network design
![[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world](/img/41/76687ea13e1722654b235f2cfa66ce.png)
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac

How much memory does bitmap occupy in the development of IM instant messaging?
随机推荐
String of sword finger offer question bank summary (II) (C language version)
wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
[advanced mathematics] [5] definite integral and its application
移动web布局方法
Jmeter——接口测试
Digital informatization (enumerate assumptions first, and then see whether the conditions are met) (1089 werewolf kill - simple version)
RF, gbdt, xgboost feature selection methods "recommended collection"
Kubernetes进阶部分学习笔记
Log in to Baidu online disk with cookies (websites use cookies)
QML combines qsqltablemodel to dynamically load data MVC "recommended collection"
【TensorRT】trtexec工具转engine
Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
FormatDateTime说解[通俗易懂]
Formatdatetime explanation [easy to understand]
tga文件格式(波形声音文件格式)
[advanced mathematics] [6] differential calculus of multivariate functions
PMP practice once a day | don't get lost in the exam -7.25
CarSim simulation quick start (XV) - ADAS sensor objects of CarSim sensor simulation (1)
[today in history] June 30: von Neumann published the first draft; The semiconductor war in the late 1990s; CBS acquires CNET
Successfully solved typeerror: a bytes like object is required, not 'str‘