i need a function: readData() to read in scores from a file.
I can open a file up, but not sure how to code it so input from the user opens any file.

int readData()
{
    cout << "Please enter in the path to the student score file: " << endl;

        cin >> theFile;

        ifstream theFile("grades.txt");

}

I need to use an array to store all the scores. I think i need to replace grades.txt with somthing?

use getline when the file name may or may not contain spaces.

int readData()
{
    std::string filename;
    cout << "Please enter in the path to the student score file: " << endl;

    getline(cin,filename);

        ifstream theFile(filename.c_str());

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.