Reading a file into an array

Trying to read from file into an array. Don't understand what this error is, "no matching function for call to 'std::basic_ifstream<char>::open(std::__cxx11::string&)'
in_stream.open(sales_file);"

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
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{

int first, sales[20], i;
string sales_file;
ifstream in_stream;

cout << "What is the name of the file for the sales?\n";
cin >> sales_file;
in_stream.open(sales_file);


   for(i = 0; i < 20; ++i)
      {
      sales_file >> sales[i]
      }
      

in_stream.close();
}
line 21 sales_file >> sales[i]; //semi-colon added

sales_file is the string that held the name of the file input by the user. The ifstream object that was created is called in_stream.
Topic archived. No new replies allowed.