Reading text file to an array

How do I read a text file with numbers and input those numbers into an array?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <fstream>
#include <vector>

int main()
{
    std::vector<int> numbers;
    if(std::ifsream in ("numbers.txt"))
    {
        int number;
        while(in >> number)
        {
            numbers.push_back(number);
        }
    }
    else
    {
        //could not open file
    }
    //...
}
Topic archived. No new replies allowed.