c/c++语言开发共享使用C语言实现文件的操作

“`c #include int main(int argc, char* argv[]) { // 创建文件类型 FILE* file; char buf[1024] = {0, }; // a 是追加,+ 文件不存在可以进行创建 file = fopen("1.txt", "a+"); // … …

#include <stdio.h>  int main(int argc, char* argv[]) {   // 创建文件类型   file* file;   char buf[1024] = {0, };   //  a 是追加,+ 文件不存在可以进行创建   file = fopen("1.txt", "a+");   // 写入到文件 内容是hello world, 每一个字符大小是1,一共有13个字符   fwrite("hello world", 1, 13, file);      // 移动游标到文件开头   rewind(file);      // 读文件,到buf里面   fread(buf, 1, 26, file);   printf("buf: %sn", buf);      // 关闭文件   fclose(file);   return 0; }

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/600522.html

(0)
上一篇 2021年5月9日
下一篇 2021年5月9日

精彩推荐