Hello im learning c++ and i was wondering how i can call a function that will write to a file. within that function it will call other functions and will print the output. How would i do that?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void buildArray(float arrayScores[], int numOfScores);
void printOutArray(float arrayScores[], int numOfScores);
void writeToFile(float arrayScores[], int numOfScores);
int main(){
    int numOfScores;
    cout << "Enter the number of scores: "
    cin >> numOfScores;
    float *arrayScores = nullptr;
    arrayScores = new float [numOfScores];
    writeToFile(arrayScores, numOfScores);
    delete [] arrayScores;
}
void buildArray(float arrayScores[], int numOfScores){
    float score = 0;
    for (int i=0; i<numOfScores; i++){
    cout << "Enter the score: ";
    cin >> score;
    arrayScores[i] = score;
}
void printOutArray(float arrayScores[], int numOfScores){
    int Items = numOfScores;
    for (int i = 0; i<numOfScores; i++){
        float grade = arrayScores[i];
        cout << "Score number " << i+1 << ": " << arrayScores[i] << endl;
    }
}
void writeToFile(arrayScores[], int numOfScores){
    ofstream outfile;
    outfile.open("Scores.txt");
    outfile << buildArray(arrayScores,numOfScores);
    outfile << printOutArray(arrayScores,numOfScores);
    outfile.close();
}
 
    