Help with reading in rext files.

I was given these instructions for my college programming assignment, and I have done parts 1 and 2, and am having trouble on part three.

1. Use a function named PromptUser() to ask the user for a filename. It will return the
filename as a string object.
2. Open the filename for reading. If you cannot open the filename given, prompt the
user for another. Repeat this until you can open the user's file.
3. Use a function named ReadData() that will take a reference to an integer vector as
the first parameter and a reference to a file stream as the second parameter. It will
make sure the stream is open, then read all the data from the stream and place that
data into the vector. If the file is not open at the beginning of the function, the
function will return a 1, otherwise it will return 0. The main program should check
the return value of this function. If there is an error, give the user an error message
and then end the program.

Our professor gave us the functions, just without the definitions. So far this is what I have

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
string PromptUser()
{
  string filename;
  bool working = true;
  
  while(working == true)
  {
    cout << "Please enter a file name: " << endl;

    cin >> filename;

    ifstream inFile(filename);
  
    if(!inFile) 
    {
      cerr << "Could not open: " << filename << endl;
      exit(1);
    }
	else
	{
	  working = false;
	}
  }

  return filename;
}

int ReadData(vector<int>& theData, ifstream& in)


I have no idea where to begin on the second method. Any help is appreciated, thanks a ton.
Topic archived. No new replies allowed.