mọi người cho em hỏi sao ghi kiểu int thì file nhị phân lại không đọc được ạ
chỉ có mảng hoặc kiêu char thì file mới đọc được
em cảm ơn ạ
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream outfile;
outfile.open("number1.dat", ios::out|ios::binary);
int x[]={3};
outfile.write(reinterpret_cast<char*>(x), sizeof(x));
outfile.close();
ifstream infile;
infile.open("number1.dat", ios::in|ios::binary);
infile.read(reinterpret_cast<char*>(x), sizeof(x));
cout<<reinterpret_cast<char *>(x);
infile.close();
return 0;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?