... create and insert record
151   void newRecord(fstream& insertInFile) {
152      // obtain number of account to create
153      int accountNumber{getAccount("Enter new account number")};
154
155      // move file-position pointer to correct record in file
156      insertInFile.seekg((accountNumber - 1) * sizeof(ClientData));
157
158      // read record from file
159      ClientData client;
160      insertInFile.read(                                       
161         reinterpret_cast<char*>(&client), sizeof(ClientData));
162
163      // create record, if record does not previously exist
164      if (client.getAccountNumber() == 0) {
165         string lastName;
166         string firstName;
167         double balance;
168
169         // user enters last name, first name and balance
170         cout << "Enter lastname, firstname, balance\n? ";
171         cin >> setw(15) >> lastName;
172 ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.