Which of the following positions the file pointer for a file that has been opened for reading and writing?

a. Use the size() member function on the file stream to position the file pointer.
b. Use the seekp(arg) fstream member function with the number of records (counting the first record as 0) as argument to position the file pointer.
c. Use the seekp(arg) fstream member function with the number of bytes to the record in question (counting the first byte as 0) as argument to position the file pointer.
d. Use the sizeof operator to determine the number of bytes in the file stream.


Part c) is closest. I would expect my students to supply the fact that he argument must be RecordCount * sizeof(MyStruct) –1 where the –1 accounts for counting bytes from 0 .
Explanation: Part a): there is no size() member of the fstream class. Part b) is almost right but uses record count rather than byte count. Part d) only supplies the size of the stream object, but does nothing to the stream object

Computer Science & Information Technology

You might also like to view...

Can you null-terminate a numeric array?

What will be an ideal response?

Computer Science & Information Technology

How many steps are involved in the process of deleting a node?

a. one: delete the node from memory b. two: remove the node without breaking links, then delete it from memory c. three: create a blank node, remove the node being deleted, insert the blank node d. four: create a blank node, insert the blank node before the node being deleted, remove the node being deleted, delete the blank node e. None of these

Computer Science & Information Technology

Candidate keys that are not used for the primary keys are ________ keys

A) artificial B) natural C) alternate D) composite

Computer Science & Information Technology

A JavaScript ____ is an action script that allows you to add dynamic content to your web pages.

A. action B. event C. behavior D. trigger

Computer Science & Information Technology