134k views
1 vote
Given the availability of an ifstream object named input, write the other statements necessary to read an integer into a variable datum that has already been declared from a file called rawdata. Assume that reading that one integer is the only operation you will carry out with this file. (Note: write just the statements, do not define a main function.)

1 Answer

3 votes

Answer:

input.open("rawdata");

input>>datum;

input.close();

Step-by-step explanation:

ifstream objects maintain a filebuf object as their internal stream buffer, and perform operations like input/output on the available associated files.

In above statements.

input.open("rawdata");

  • The associated file named rawdata is opened.

input>>datum;

  • The integer from the file is read into already declared variable datum.

input.close();

  • Input stream is closed.
User GDB
by
5.9k points