I was trying to read the data that i wrote to a binary file using structure.
i used struct pointer to read the file but when i read through the file it is showing "the address to my hard disc files" and "Domain";
class retail
{
struct item
{
int sno;
float cost;
char code[25],name[25];
}s1,*s2,*s3;
public:
void write();
void read();
};
void retail::write()
{
fstream writer;
writer.open("Retail_Items.dat",fstream::out|fstream::app|fstream::binary);
s2=(struct item*)malloc(sizeof(item));
cout<<"\nEnter The Serial Number of The item\n";
cin>>s2->sno;
cout<<"\nEnter The Item Name\n";
cin>>s2->name;
cout<<"\nEnter The Iten Code\n";
cin>>s2->code;
cout<<"\nEnter The Item Cost\n";
cin>>s2->cost;
writer.write((char*)s2,sizeof(s2));
// delete[]s2;
writer.close();
}