i'm getting confused on the sizes of a file and an object that was written to it!!
this is the part of a program that i did:
CODE
struct EMPLOYEE{
int emp_id, phno;
char name[20],addr[50],dep[15];
float sal;
void accept(); //accept() has 1 variable of type char
};
CODE
void new_emp(){
ofstream f1("emp1.dat",ios::binary|ios::app);
EMPLOYEE s;
s.accept();
f1.write((char *)&s, sizeof(s));
f1.close();
ifstream f2("emp1.dat",ios::binary);
int n=sizeof(f2);
cout<<n<<endl; //80
n=sizeof(s);
cout<<n<<endl; //93
f2.close();
}
surprisingly the size of object(struct) is 93 and that of file is 80
file is smaller than object!!!
how???
i'm using turbo C++ and size of int=2 bytes, char=1 byte, float=4 bytes
This post has been edited by dan_ram: 14 Oct, 2008 - 07:13 AM