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.)

Respuesta :

CPED

Answer:

input.open("rawdata");

input>>datum;

input.close();

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.