写(fwrite)/读(fread)文件
发布日期:2021-07-01 06:04:41 浏览次数:2 分类:技术文章

本文共 436 字,大约阅读时间需要 1 分钟。

 本代码是在Ubuntu下搞的。

#include 
#include
int main(){ FILE *fp = NULL; char a[]="helloworld"; fp = fopen("/home/hlpan/桌面/myfile/demo0/test.txt", "w+"); fwrite(a,strlen(a)-1,1,fp); fclose(fp);}
#include 
#include
int main(){ FILE *fp = NULL; char buff[11]={0}; fp = fopen("/home/hlpan/桌面/myfile/demo0/test.txt", "r"); fread(buff,sizeof(buff),1,fp); printf("%s\n", buff ); fclose(fp);}

 

转载地址:https://pantang.blog.csdn.net/article/details/115731340 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:shell 脚本中$$,$#,$?分别代表什么意思?
下一篇:linux几种时间函数总结

发表评论

最新留言

不错!
[***.144.177.141]2024年04月28日 15时22分10秒