Every time I write in file using ofstream it works fine except for one thing that when the file is re-opened after writing something and we try to add more data then previously added data is removed how to get rid of this.


struct abc
char name[100];
int a;

int main()

ofstream file;
file.open("text.dat", ios:ut | ios::binary);

abc x;

x.a = 2;
cout<<"Enter name ";

file.write((char*)&x,sizeof(struct abc));

return 0;