2 binary files

closed account (STR9GNh0)
how to read out 1 binary files and edit/update/append the other accordingly ?

eg..

binary file 1 have a few data
- 1. ABC
- 2. CDE
- 3. FGH
...etc

binary file 2 (currently empty) but returns
- ABC

when in binary file 2 i call for 1 it returns ABC and save into it.


Last edited on
closed account (STR9GNh0)
void constructBinary (fstream& afile, char fileName [], int n)
{
afile.open (fileName, ios::out | ios::binary); //struct Order.dat

fileTesting (afile, fileName);

int quantity;
char yesNo;
Items itms;
Order ord;

cout << "Please place your order\n"
<< "May i have your name?: ";
cin.ignore(MAX,'\n');
cin.getline(ord.name, MAX);

do
{


int a;
a = n;


cout << "Item No: ";
cin >> a;
cout << itms.serviceItem;

if(a > n)
{
cout << "invalid item entered\n";
}




cout << "How many?: ";
cin >> quantity;
itms.quantity = quantity;


afile.write (reinterpret_cast <const char *> (&itms), sizeof (itms));

cout << "Any more order? (Y/N): ";
cin >> yesNo;

}while (yesNo == 'y' || yesNo == 'Y');

afile.close ();
}
Last edited on
closed account (STR9GNh0)
any one ?
Topic archived. No new replies allowed.