关于二进制文件的读写问题,50分啦!
程序代码:#include <fstream>
#include <string>
using namespace std;
int main()
{int student[5]={1,2,3,4,5}; ofstream outfile("student.dat",ios::binary);
outfile.write((char*)&student[0],sizeof(student));
outfile.close();
ifstream infile("student.dat",ios::binary);
infile.read((char*)&student[0],sizeof(student));
infile.close();
return 0;
}打开student.dat文件后,在行的最后面出现乱码,原因?谁能详细解释下关于二进制的读写问题?最好举例子!谢谢大家
后面的是神马情况?
谢谢大家的回答。
[ 本帖最后由 gmac 于 2011-3-2 17:10 编辑 ]








