C++文件操作

https://blog.csdn.net/shenziheng1/article/details/79472102

 #include<stdio.h>

C++ fopen/fwrite/fread

文件写入:

FILE * fp;
fp = fopen("data.txt","w");
if (fp != NULL)
{
  fwrite(data, sizeof(char), size, fp); 
  fclose(fp);
}

文件读取:

FILE * fp;
fp = fopen("/home/leinao/test/myfile.txt","r");
if (fp != NULL)
{
    size_t bytes_read = fread(data, sizeof(char), size, fp);
    printf("Read Bytes: %d
", bytes_read);
    fclose(fp);
}
原文地址:https://www.cnblogs.com/lucifer1997/p/11869493.html