#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
struct status{
char name[80];
double balance;
unsigned long account_num;
};
struct status acc;
strcpy(acc.name,"Ralph Trantor");
acc.balance = 1123.23;
acc.account_num = 34235678;
//write data
ofstream outbal("balance", ios::out | ios::binary);
if(!outbal){
cout<<"Cannot open file.\n";
return 1;
}
outbal.write((char*) &acc,sizeof(struct status));
outbal.close();
ifstream inbal("balance",ios::in | ios::binary);
if(!inbal){
cout<<"Cannot open file.\n";
return 1;
}
inbal.read((char *) &acc, sizeof(struct status));
cout<
cout.setf(ios::fixed);
cout<
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar