Array/File FunctionsWrite a function named arrayToFile. The function should accept three arguments:the name of a file, a pointer to an int array, and the size of the array. The functionshould open the specified file in binary mode, write the contents of the array to the file,and then close the file.Write another function named fileToArray. This function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. Thefunction should open the specified file in binary mode, read its contents into the array,and then close the file.Write a complete program that demonstrates these functions by using the arrayToFilefunction to write an array to a file, and then using the fileToArray function to readthe data from the same file. After the data are read from the file into the array, displaythe array’s contents on the screen.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question

Array/File Functions
Write a function named arrayToFile. The function should accept three arguments:
the name of a file, a pointer to an int array, and the size of the array. The function
should open the specified file in binary mode, write the contents of the array to the file,
and then close the file.
Write another function named fileToArray. This function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The
function should open the specified file in binary mode, read its contents into the array,
and then close the file.
Write a complete program that demonstrates these functions by using the arrayToFile
function to write an array to a file, and then using the fileToArray function to read
the data from the same file. After the data are read from the file into the array, display
the array’s contents on the screen.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr