stranger_in_rain
Member
زبان : سي
كامپايلر: توربو سي
مسئله: ذخيره تعداد 10 عضو يك آرايه در يك فايل dat
كامپايلر: توربو سي
مسئله: ذخيره تعداد 10 عضو يك آرايه در يك فايل dat
کد:
#include<iostream.h>
#include<fstream.h>
int main()
{
int temp , a[ 5 ] = { 1 , 2 , 3 , 4 , 5 } ;
ofstream myfile( "info.dat" , ios::out | ios::binary );
if ( !myfile )
{
cout<<"FATAL ERROR \n Cant open the file ... \n";
getch();
exit(0);
}//end of checking file availability
for (j=0;j<5;i++)
{
temp = a[i];
myfile.write((char *) &temp, sizeof( int ));
}//end of for
myfile.close();
}//end of program