Putting Numbers from a File into an Array

I am currently trying to place the numbers in the file into the array. I keep getting the following error "invalid operands of types 'char [16]' and 'int' to binary 'operator>>'
in_file_name >> sales[i]"

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

using namespace std;

int main()
{

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

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


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

in_stream.close();
}
"its not working" is not a helpful description of the problem. What is the problem? A compiler error? A linker error? A runtime crash? Some other behaviour?

It may surprise you to learn that very few of us here on this forum are telepaths. There's a remarkably low overlap between telepaths and software developers - don't ask me why, but those pesky telepaths just don't seem to be interested in C++ like we non-telepaths are.

One unfortunate consequence of this is that we can't read your mind. We can't magically know what you are seeing on your computer. If you want us to help you with a problem, you have to give us all the information about that problem.
Topic archived. No new replies allowed.