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
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started