当前位置:网站首页>C language file cursor fseek
C language file cursor fseek
2022-06-26 19:27:00 【laocooon】
// Write file by block
struct Hero
{
char name[64]; // full name
int age; // Age
};
void test02()
{
FILE* fp = NULL;
fp = fopen("fseek.txt", "w");
if (fp == NULL)
{
printf(" File opening failure \n");
return;
}
struct Hero heros[4] = {
{ " The Monkey King ", 33 },
{ " Han xin ", 28 },
{ " zhaoyun ", 45 },
{ " Arthur ", 35 }
};
for (int i = 0; i < 4; i++)
{
// Parameters 1 First address of data Parameters 2 Block size Parameters 3 Number of pieces Parameters 4 The file pointer
fwrite(&heros[i], sizeof(struct Hero), 1, fp);
}
// Close file
fclose(fp);
//fseek function Perform random position reading
FILE* fp2 = NULL;
fp2 = fopen("fseek.txt", "r");
if (fp2 == NULL)
{
printf(" File opening failure \n");
return;
}边栏推荐
- xlua获取ugui的button注册click事件
- 成功解决之idea引用Lombok的@Slf4j后无法正常使用log
- 50 lines of code to crawl TOP500 books and import TXT documents
- Project practice 4: user login and token access verification (reids+jwt)
- NFTGameFi链游系统开发详解方案丨链游系统开发原理解析
- Development principle analysis and source code of dapp-lp single and dual currency liquidity pledge mining system
- JS mobile terminal touch screen event
- Vscode 基础必备 常用插件
- Boot的单元测试
- Filebeat安装及使用
猜你喜欢

Six necessary threat tracking tools for threat hunters

Project practice 4: user login and token access verification (reids+jwt)

Feign远程调用

抖音实战~分享模块~短视频下载(保存到相册)

抖音实战~首页视频~下拉刷新

Some cold knowledge about QT database development

黑客用机器学习发动攻击的九种方法

商品秒杀系统

抖音实战~分享模块~生成短视频二维码

Tiktok practice ~ homepage video ~ pull-down refresh
随机推荐
Handwritten numeral recognition based on tensorflow
Example of using QPushButton style (and method of adding drop-down menu to button SetMenu)
Convex hull problem
xlua获取ugui的button注册click事件
黑客用机器学习发动攻击的九种方法
抖音实战~分享模块~生成短视频二维码
Using recursion to find all gray codes with n bits
Installation and use of filebeat
问题解决:虚拟机无法复制粘贴文件
一些基本错误
WebView load pdf
Microservice architecture
自己创建一个时间拦截器
深度学习之Numpy篇
redis 基础知识
Solve com mysql. jdbc. exceptions. jdbc4.MySQLNonTransientConnectionException: Could not create connection
手机影像内卷几时休?
Solidity - contract inheritance sub contract contains constructor errors and one contract calls the view function of another contract to charge gas fees
限流设计及实现
抖音实战~分享模块~短视频下载(保存到相册)