小学生古诗配图大全.:C++如何把全部私有数据存入磁盘文件里

来源:百度文库 编辑:中科新闻网 时间:2024/05/06 12:29:58
我要的是C++程序语句 最好有列子

#include <stdio.h>

class AA
{
int a;
int b;
float c;
public;
int Save(const char* file);
};

int AA::Save(const char* file)
{
FILE* fp = NULL;
fp = fopen(file, "wb");
if(NULL == fp)
return 0;

fwrite(&a, sizeof(int), 1, fp);
fwrite(&b, sizeof(int), 1, fp);
fwrite(&c, sizeof(float), 1, fp);

fclose(fp);
return 1;
}