df

#include <iostream>

using namespace std;

#include <fstream>

#include <cstdlib>

int main()

{

char b=EOF;

int a[1]={'/0'};

int buffer[10]={1,2,3,4,5,6,7,8,9,0};

fstream file("bfile.dat",ios::out|ios::binary);

cout << "首先向文件种写数据。。。" << endl ;

file.write((char *)buffer,sizeof(buffer));

file.close();

cout << "写入数据成功" << endl;

file.open("bfile.dat",ios::in);

if (file.fail())

{

cout << "fail!!" << endl;

exit(0);

}

cout << "打开文件数据" << endl;

file.read((char *)buffer,sizeof(buffer));

for (int count=0;count <10;count++)

{

cout << buffer[count] << " ";

}

file.close();

return 0;

}

你可能感兴趣的:(df)