#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: %s\n", buf);
// 關閉檔案
fclose(file);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/54955.html
標籤:C
