... cin >> lastName; 32         cin >> firstName;
33         cin >> balance;
34
35         // create ClientData object
36         ClientData client{accountNumber, lastName, firstName, balance};
37
38         // seek position in file of user-specified record
39         outCredit.seekp(                                         
40            (client.getAccountNumber() - 1) * sizeof(ClientData));
41
42
43         // write user-specified information in file
44         outCredit.write(                                               
45            reinterpret_cast<const char*>(&client), sizeof(ClientData));
46
47         // enable user to enter another account
48         cout << "Enter account number\n? ";
49         cin >> accountNumber;
50      }
51   }

Enter account number (1 to 100, 0 to end input)
? 37
Enter lastname, firstname and balance
? Barker Doug 0.00
Enter account number
? 29
Enter lastname, firstname and balance
? Brown Nancy -24.54 Enter ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.