Write a function named readData that gets data from a file and populates the arr
ID: 3623678 • Letter: W
Question
Write a function named readData that gets data from a file and populates the array(s) to read the data.The data file from which your getting the data from is named data.in
The data, we have (in this order) A,B, and C. If we use a 1 to mean the data set is present and a 0 to mean it is not and follow that with the data set sizes: 1 1 0 40
would mean we have A and B but C. The size of the A data and the B data set is size 40. 0 1 0 40 would mean we have only B in the file and the data set is size 40.
Any help would be greatly appreciated. Even psuedocode or any kind of steps to take.
Here's is an example program that populates an array if it helps solve the above:
#include<iostream>
using namespace std;
//------------------------------------------------------------------------------
//
// testFunc()
//
// A function that receives an array it's size and a value to set the array to.
// The point of this function is to demonstrate that arrays are passed
// by reference, not value.
//
//------------------------------------------------------------------------------
int testFunc(int array[], int arraySize, int value)
{
for(int i = 0; i < arraySize; i++) array[i] = value;
}
int main()
{
const int arraySize = 10;
int array[arraySize];
// Populate the test array.
testFunc(array, arraySize, 1);
// Print out the test array.
for(int i = 0; i < arraySize; i++) cout << array[i] << " ";
cout << endl;
// Change the array values from 1->0.
testFunc(array, arraySize, 0);
// Print out the test array.
for(int i = 0; i < arraySize; i++) cout << array[i] << " ";
cout << endl;
system("pause");