//c的输入输出二进制文件
#include"aa.h"
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<fstream>
#include<string>
using namespace std;
struct test
{
int i;
char j[10];
};
int main()
{
test test1={1,"test"},test2;
ofstream pf("a1.txt",ios_base::binary);
pf.write((const char *)&test1,sizeof(test));
pf.close();
ifstream pf1("a1.txt",ios_base::binary);
pf1.read((echar *)&test2,sizeof(test));
printf("%d %s\n",test2.i,test2.j);
pf1.close();
return 0;
}
//c++的输入输出二进制文件
#include"aa.h"
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<fstream>
#include<string>
using namespace std;
struct test
{
int i;
char j[10];
};
int main()
{
test test1={1,"test"},test2;
FILE *pf;
pf=fopen("a1.txt","wb");
fwrite(&test1,sizeof(test),1,pf);
fclose(pf);
pf=fopen("a1.txt","rb");
fread(&test2,sizeof(test),1,pf);
fclose(pf);
printf("%d %s\n",test2.i,test2.j);
return 0;
}
#include"aa.h"
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<fstream>
#include<string>
using namespace std;
struct test
{
int i;
char j[10];
};
int main()
{
test test1={1,"test"},test2;
ofstream pf("a1.txt",ios_base::binary);
pf.write((const char *)&test1,sizeof(test));
pf.close();
ifstream pf1("a1.txt",ios_base::binary);
pf1.read((echar *)&test2,sizeof(test));
printf("%d %s\n",test2.i,test2.j);
pf1.close();
return 0;
}
//c++的输入输出二进制文件
#include"aa.h"
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<fstream>
#include<string>
using namespace std;
struct test
{
int i;
char j[10];
};
int main()
{
test test1={1,"test"},test2;
FILE *pf;
pf=fopen("a1.txt","wb");
fwrite(&test1,sizeof(test),1,pf);
fclose(pf);
pf=fopen("a1.txt","rb");
fread(&test2,sizeof(test),1,pf);
fclose(pf);
printf("%d %s\n",test2.i,test2.j);
return 0;
}