Skip to Content
C++ How to Program, 10/e
book

C++ How to Program, 10/e

by Paul Deitel, Harvey Deitel
February 2016
Beginner
1080 pages
207h 57m
English
Pearson
Content preview from C++ How to Program, 10/e
... 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ How to Program, Sixth Edition

C++ How to Program, Sixth Edition

P. J. Deitel - Deitel & Associates, Inc., H. M. Deitel - Deitel & Associates, Inc.
C++ How to Program, Ninth Edition

C++ How to Program, Ninth Edition

Paul Deitel, Harvey Deitel

Publisher Resources

ISBN: 9780134448930Purchase book