当前位置:网站首页>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;
}
边栏推荐
- PMP adopts the latest exam outline, here is [agile project management]
- What is cluster analysis? Categories of cluster analysis methods [easy to understand]
- The use of new promise, async and await in the project, and the practical application of promise.all in the project
- Dataloader reports an error "default_collate: batch must contain tensors, numpy arrays, numbers, dicts" when pytorch trains the model
- Dataframe first performs grouping operation and then combines output
- FanoutExchange交换机代码教程
- MySQL 日期【加号/+】条件筛选问题
- 【高等数学】【1】函数、极限、连续
- 2022.7.24-----leetcode.1184
- Digital informatization (enumerate assumptions first, and then see whether the conditions are met) (1089 werewolf kill - simple version)
猜你喜欢

Recommended system topic | Minet: cross domain CTR prediction

Stochastic gradient descent method, Newton method, impulse method, adagrad, rmsprop and Adam optimization process and understanding

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

Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released

Docker builds redis cluster

Jmeter——接口测试

Working principle of radar water level gauge and precautions for installation and maintenance

谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞

JVM(二十三) -- JVM运行时参数

【高等数学】【6】多元函数微分学
随机推荐
FanoutExchange交换机代码教程
CarSim仿真快速入门(十五)—CarSim传感器仿真之ADAS Sensor Objects (1)
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
2022.7.24-----leetcode.1184
Interpretation of repartitioned network structure in repvgg network [with code]
tga文件格式(波形声音文件格式)
Is QQ 32-bit or 64 bit software (where to see whether the computer is 32-bit or 64 bit)
9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence
参与开源社区还有证书拿?
【高等数学】【6】多元函数微分学
[today in history] June 28: musk was born; Microsoft launched office 365; The inventor of Chua's circuit was born
[today in history] July 8: PostgreSQL release; SUSE acquires the largest service provider of k8s; Activision Blizzard merger
JVM(二十三) -- JVM运行时参数
When AI encounters life and health, Huawei cloud builds three bridges for them
什么是聚类分析?聚类分析方法的类别[通俗易懂]
LP dual currency pledge liquidity mining DAPP system development logic analysis
【高等数学】【5】定积分及应用
[today in history] June 30: von Neumann published the first draft; The semiconductor war in the late 1990s; CBS acquires CNET
Recommendations on how to install plug-ins and baby plug-ins in idea
Formatdatetime explanation [easy to understand]