当前位置:网站首页>Fopen, fwrite, fseek, fTell, FREAD use demo
Fopen, fwrite, fseek, fTell, FREAD use demo
2022-07-24 07:28:00 【Fried meat with eggs】
#include <stdio.h>
#include <stdlib.h>
#include <string.h>int main() {
int ret = 0;
char buf[] = “mr liu yyds”;
char readbuf[128] = {0};
FILE *fp;
fp = fopen(“fopen.txt”, “w+”);
if (NULL == fp)
{
printf(“fopen fail\n”);
return 0;
}
if (1 != fwrite(buf, strlen(buf), 1, fp))//fputc fputs
{
printf(“fwrite fail\n”); goto error;
}
if (fseek(fp, 0, SEEK_END))
{
printf(“fseek fail\n”); goto error;
}
ret = ftell(fp);
if (!ret)
{
printf(“ftell fail\n”); goto error;
}
fseek(fp, 0, SEEK_SET);
if (0 == fread(readbuf, ret, 1, fp))
{
printf(“fread fail\n”); goto error;
}
printf(“readbuf[%s]\n”, readbuf); error:
fclose(fp);
return 0; }
边栏推荐
- Feature Selective Anchor-Free Module for Single-Shot Object Detection
- Development system selection route
- Write three piece chess in C language
- 【PTA】团体程序设计天梯赛-练习集 L3题目总结(不全)
- Source code analysis of Nacos configuration center
- QoS quality of service three DiffServ Model message marking and PHB
- Injectfix principle learning (to realize the heat of repair addition)
- InjectFix原理学习(实现修复加法的热更)
- Network security B module windows operating system penetration test of national vocational college skills competition
- SPI - send 16 bit and 8-bit data
猜你喜欢

Simple installation of sqli Labs

From the perspective of CIA, common network attacks (blasting, PE, traffic attacks)
![[FreeRTOS] 11 software timer](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[FreeRTOS] 11 software timer

Kali installing PIP and pip source changing

我的创作纪念日

XSS漏洞学习

Single Gmv has increased 100 times. What is the "general rule" behind the rise of popular brands?

Vulnhub DC1

Jay Chou's live broadcast was watched by more than 6.54 million people, with a total interaction volume of 450million, helping Kwai break the record again

What kind of mode can make platform users self-help fission- Chain 2+1
随机推荐
Win10 sound icon has no sound
Riotboard development board series notes (IX) -- buildreoot porting matchbox
Influxdb未授权访问&CouchDB权限绕过
Nacos的高级部分
Laplace distribution
OpenCascade笔记:gp包
24. Global event bus
baddy:核心函数入口
无法自动装配,未找到“RedisTemplate类型的Bean
学习笔记-分布式事务理论
QoS quality of service 4 traffic regulation of QoS boundary behavior
[word] how to generate the index directory on the left
MITRE ATT&CK超详细学习笔记-01(背景,术语,案例)
Blockbuster live broadcast | orb-slam3 series code explanation map points (topic 2)
The goal you specified requires a project to execute but there is no POM in this directory
R language handwritten numeral recognition
JMeter notes 2 | JMeter principle and test plan elements
JS的DOM操作——style的操作
Aggregated new ecological model - sharing purchase, membership and reward system
Customization or GM, what is the future development trend of SaaS in China?