Delete a record that contains information by reinitializing that particular record.

What will be an ideal response?


```
do { // obtain id-number value
cout << "Enter id number for new record (1 - 100): "
cin << id;
} while ((id < 1) || (id > 100));
// move file-position pointer to correct record in file
fileObject.seekg((id - 1) * sizeof(Person));
// read record from file
Person person;
fileObject.read(reinterpret_cast(&person), sizeof(Person));
if (person.id != 0) { // delete record, if record exists in file
// create blank record
Person blankPerson;
blankPerson.setLastName("unassigned");
blankPerson.setFirstName("");
blankPerson.setAge("0");
blankPerson.id = 0;
// move file-position pointer to correct record in file
fileObject.seekp((id - 1) * sizeof(Person));
// replace existing record with blank record
fileObject.write(reinterpret_cast(&blankPerson),
sizeof(Person));
cout << "Record #" << id << " deleted." << endl;
}
else { // display error if record does not exist
cerr << "Record #" << id << " is empty." << endl;
}
```

Computer Science & Information Technology

You might also like to view...

Classes and methods reveal low-level implementation details.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What do the format specifiers d, f, e, g, s and c represent?

What will be an ideal response?

Computer Science & Information Technology

A technician is working at a client’s office after hours and needs two cables to finish the work but does not have immediate access to prebuilt cables. One cable needed is for a dial-up connection from the dial-up modem to the existing analog POTS jack on the wall. The other cable is for an Ethernet connection from the computer to the existing keystone jack on the wall. The technician has the necessary wire and connectors to make the cables.   Which of the following tools will the technician use to make the cables and then verify that they both work properly? (Select THREE.)

A. Crimper B. Toner probe C. Cable tester D. Cable stripper E. Punchdown tool F. Loopback plug

Computer Science & Information Technology

Case-Based Critical Thinking Question ? Scott is the website administrator for a large pet food manufacturer. It plans to sell its products online and wants to test its retail website. Scott hires an intern to help with the project, and realizes that the new intern has uploaded all of the testing pages to the final upload location on the web server.  Scott tells the intern the following: ____.

A. "Good job. That is exactly where they go." B. "That is not a good location because all the pages are now available to the public." C. "That is not a good location because ‘testing' pages should never be put on a server." D. "The pages will not appear on the server because the pages should have been downloaded, not uploaded."

Computer Science & Information Technology