Question: write a program that does file I/O in binary mode Write a program that prompts the user inputs the name of the input file, using
write a program that does file I/O in binary mode
Write a program that
prompts the user
inputs the name of the input file, using getline
(You may assume without checking that the call to getline introduces no error)
tries to open the input file in binary mode (ios::binary)
c&d if the attempt to open is unsuccessful
prompts the user
inputs the name of the output file, using getline
(You may assume without checking that the call to getline introduces no error)
tries to open the output file in binary mode (ios::binary)
c&d if the attempt to open is unsuccessful
prompts the user
inputs the name of the second output file, using getline
(You may assume without checking that the call to getline introduces no error)
tries to open the second output file in binary mode (ios::binary)
c&d if the attempt to open is unsuccessful
(I hope you agree that a function the opens a binary output file would be a good
idea.)
Loop:
read a byte from the input file, write the byte to the first output file,
read a byte from the input file, write the byte to the second output file,
read a byte from the input file, write the byte to the first output file,
read a byte from the input file, write the byte to the second output file,
and so on for as many byte as the input file has.
If the input fails without EOF, c&d
Close both output files.
If either output file is in an error state, c&d
Close the input file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
