write a function that will take three parameters-an array, a number indicating t
ID: 3567545 • Letter: W
Question
write a function that will take three parameters-an array, a number indicating the maximum size of the array and a filename. The function will open the file, read whole numbers from the file, store them in the array, and reutrn the count of numbers via the return statement. The numbers to be read may have up to 19 digits. Make use of appropriate data types for the parameters, local variables, and the function return value. Your function may read fewer numbers than the maximum but never more. Use appropriate conditions and checks. you may assume all required libraries are included.
Explanation / Answer
int myFunction(string arr[], int maxSize, char fileName[]){
int count = 0;
string temp;
ifstream inFile(fileName);
while(inFile >> temp){
arr[count] = temp;
count++;
if(count == maxSize) break;
}
return count;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.