C programming Language(文件操作)

打开

FILE * fpointer;
f = open("path","mode");

模式

modes:
r,w,a
read write append
r+,w+,a+

读写

格式化读写

format read & write
int fscanf (FILE* stream, const char* format,[argument]);

fprintf (stdout,const char *format,[argument]);

按字符/字符串读写

int putchar(int c); //

int putc(int c,FILE *fp);  //宏实现

/*每读出一个字符,将指针下移*/
int fputc(int c,FILE *fp);//函数

int puts(const char *s);
int fputs(const char* s, FILE *fp); //不添加\n

int getchar(void); //

int getc(FILE *fp);  //宏实现

/*每读出一个字符,将指针下移*/
int fgetc(FILE *fp); //函数

char *gets(char *s); //不保留\n ,换成 \0
//读取 n-1个字符
char *fgets(char *s, int n, FILE *fp);

位置

返回位置

long ftell(FILE *fp);
int feof(FILE *fp); //非零代表读到了文件尾巴,或者出错

改变位置

void rewind(FILE *fp);
//offset 偏移量
int fseek(fp, long offset, origin);

		 SEEK_SET  //开头
origin:   SEEK_CUR //当前位置
			SEEK_END	//末尾

按数据块读写文件

size_t fread(void *buffer, size_t size, size_t count, FILE *stream);
size_t fwrite(void *buffer,size_t size, size_t count, FILE *stream);

int buffer[10];
fwrite(buffer,sizeof(int),10,fp);
fread(buffer, sizeof(int),10,fp);

文件缓冲

//输出缓冲
fflush(fp) //清洗输出流(写入输出设备)
//输入缓冲 :保存到缓冲区(内存上)

fclose(f);
Description: Embedded software is in almost every electronic device designed today. There is software hidden away inside our watches, microwaves, VCRs, cellular telephones, and pagers; the military uses embedded software to guide smart missiles and detect enemy aircraft; communications satellites, space probes, and modern medicine would be nearly impossible without it. Of course, someone has to write all that software, and there are thousands of computer scientists, electrical engineers, and other professionals who actually do. Each embedded system is unique and highly customized to the application at hand. As a result, embedded systems programming is a widely varying field that can take years to master. However, if you have some programming experience and are familiar with C or C++, you're ready to learn how to write embedded software. The hands-on, no-nonsense style of this book will help you get started by offering practical advice from someone who's been in your shoes and wants to help you learn quicklyThe techniques and code examples presented here are directly applicable to real-world embedded software projects of all sorts. Even if you've done some embedded programming before, you'll still benefit from the topics in this book, which include:* Testing memory chips quickly and efficiently * Writing and erasing Flash memory * Verifying nonvolatile memory contents with CRCs * Interfacing to on-chip and external peripherals * Device driver design and implementation * Optimizing embedded software for size and speed So whether you're writing your first embedded program, designing the latest generation of hand-held whatchamacalits, or simply managing the people who do, this book is for you.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘亿妃

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值