Write C++ code to open a file from main(), and name the file “binary_output.binary”.

computer science

Description

Write C++ code to accomplish the following tasks.

 

1.      Write C++ code to open a file from main(), and name the file “binary_output.binary”.  Create an array of 100 numbers, 1 through 100, and write this array to the binary file. Then close the binary file, open it again, and then read from the file. Copy the file contents into a second array, and then print the array.

 

2.      Write C++ code to pass a file stream object from main into a function.  Write the numbers 1…5 to the file and close it.  Then reopen the file and use a while-loop to print and read until the end of the file.


3.      Write C++ code to create a class called Book. 

The Book class has two private member variables called page and count.

It also has a default constructor, two functions to get copies of the member variables, and two functions to modify the member variables.


Correct the syntax and logic errors (debug) the following code and state the output after you correct the code.  Feel free to use visual studio, pocket c++, or other favorite c++  compiler.



Related Questions in computer science category