Saturday 26 April 2014

files in c++


#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
int main()
{
int height[4]={3,52,4,354};
ofstream temp;
temp.open("file_5.txt");
temp.write((char*) &height , sizeof(height));
temp.close();
for(int i=0;i<4;i++)
{
height[i]=0;
}
ifstream temp1;
temp1.open("file_5.txt");
temp1.read((char*) &height , sizeof(height));
for(int j=0;j<4;j++)
{
cout<<height[j]<<endl;
}
getch();    return 0;
}

No comments:

Post a Comment