Question: 8 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,

8 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 arrays contents on the screen.

Example output:

Here are the numbers we are writing to the file: 1 2 3 4 5 6 7 8 9 10

Here are the numbers we read from the file: 1 2 3 4 5 6 7 8 9 10

Press any key to continue . . .

Submit file Assignment 6.cpp for grading

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!